We will build a Python programme A1Q2.py to display formatted messages in this problem….

Sure, here is the Python program A1Q2.py that displays formatted messages based on the given instructions: ```python def display_message(): # Step 1: Ask user to input a string message user_input = input("Enter a string message, including your name and a short message (less than 40 characters): ") # Step 2: Ask user to input a field width greater than 40 width = int(input("Enter a positive integer greater than 40 as a field width: ")) # Step 3: Ask user to input an alignment method alignment = input("Enter an alignment method [left, right, center]: ") # Step 4: Format and display the message print("+" + "-" * width + "+") formatted_message = f"|{user_input:{alignment}{width-2}}|" print(formatted_message) print("+" + "-" * width + "+") # Call the display_message function display_message() ``` This program prompts the user to input a string message, a field width greater than 40, and an alignment method. It then formats and displays the message inside a box according to the given width and alignment. The box is created using '+' and '-' characters. Note that the program assumes valid inputs from the users, such as a string message that is less than 40 characters including the name, a positive integer greater than 40 as the field width, and a valid alignment method ('left', 'right', or 'center'). You can run this program by saving it as A1Q2.py and executing it using a Python interpreter.

Sure, here is the Python program A1Q2.py that displays formatted messages based on the given instructions: “`python def display_message(): # Step 1: Ask user to input a string message user_input = input(“Enter a string message, including your name and a short message (less than 40 characters): “) # Step 2: Ask user to input a field width greater than 40 width = int(input(“Enter a positive integer greater than 40 as a field width: “)) # Step 3: Ask user to input an alignment

Read More

You have been assigned to create a simple stopwatch application for fitness enthusiasts. Develop…

You have been assigned to create a simple stopwatch application for fitness enthusiasts. Develop this using Java’s Swing GUI framework. The requirements for your stopwatch application are: • Display elapsed time in the format: HH:MM:SS. • Incorporate a “Start” button to initiate the stopwatch. • Incorporate a “Stop” button to halt the stopwatch. • Incorporate a “Reset” button to reset the elapsed time to 00:00:00. • Ensure that the application layout is easy-to-use and interactive for users.

Read More

You are a software engineer at RedPanda Software, and you have been assigned to design a…

You are a software engineer at RedPanda Software, and you have been assigned to design a desktop-based calendar application. Utilize Java’s Swing GUI framework to create a 12-month calendar application with the following specifications: • The application should display only one month at a time. • Users should be able to navigate forwards and backwards between the months. • The current day of the month should be distinctly highlighted. • Design the application interface to be intuitive and ensu

Read More

Large Integers Part \#1 Largelnteger Class An array can be used to store large integers, one digit…

Large Integers Part #1 Largelnteger Class An array can be used to store large integers, one digit at a time. For example, the integer 1234 could be stored in the array num by setting num[0] to 1, num[1] to 2, num[2] to 3, num[3] to 4. However, for this class implementation, you might find it more useful to store the digits backward; that is, place 4 in num[0], 3 in num[1], 2 in num[2], and 1 in num[3]. For the sake of simplicity, we will be storing and manipulating only with positive large integers. Implement a class named Largelnteger that stores a large integer as an array of its digits. Class must extend HasState class (provided). This is needed to make sure clone() method is written correctly. Class must have the following: - Fields - Constant arraySize must be set to 23 - Partially filled array of integers of length 23 - int digitCount keeps the number of digits in large integer, e.t. how many elements of the partially filled array are used to store the number - No-argument constructor that stores number 0 in the array. Sets digitCount to 1 - Constructor that takes a string as a parameter. The constructor parses the given string and converts it into Large Integer by storing digits in the partially filled array. - Create a new custom Exception class called LargelntegerNumberFormatException. The constructor throws exceptions of this type when - string is too long to be stored as a 23-digit number or - when string is empty or - when the string contains non-digits and thus cannot be converted into a number. - Constructor that takes a number of type long as a parameter and builds an object from it by storing digits in an array. - This constructor also throws a custom LargelntegerNumberFormatException when a parameter passed to the constructor is a negative number. - getDigitCount() accessor to the digit count variable. - toString() method that converts an array into a string of numbers in the correct order. Number 12345 is converted into a string "12345" - add(Largelnteger) method that returns the sum of this integer and the one passed as a parameter. The method adds two large integers by implementing the usual "paper and pencil" addition algorithm. This is when the backward storage arrangement of those numbers in arrays will pay off. Carry-over will be easier to do when the integer is stored backward. - Create another custom Exception class called LargelntegerOverflowException. If the resulting number is more than 23 digits long, the add() method throws a LargelntegerOverflowException type exception. - Implement clone() method. - Make your class implement Relatable interface. Code of the interface is provided. Implement all three methods of the Relatable interface. Part #2 Polymorphic Class This class exists only to house one static method called isSorted(). The method must take an array of objects of type Relatable and check if the array is sorted with the help of methods of Relatable interface. The method returns true if the array is sorted and false if it is not. The whole purpose of this exercise is to illustrate the concept of polymorphism. The purpose of this class is to house three static methods. 1. Method void writeLargelntegerArray(Largelnteger[], String) takes an array of Large Integers and a name of a file as parameters. The method writes the contents of the given array into the given binary file (in binary mode). The method throws IOExceptions. The IOExceptions may originate in the methods but must not be handled. Instead, they must be propagated to the calling code. - Make sure to add implements Serializable to the Largelnteger class header. Binary IO will fail to work without that. 2. Method Largelnteger[] readLargelntegerArray(String) method reads the contents of a binary file with the given name as an array of objects of type Largelnteger. Assume you do not know the amount of data in the file. Read data one Largelnteger object at a time and store the objects in ArrayList first. After the end of the file has been reached, convert the ArrayList into a regular array of objects that can be returned from the method. - Please study EOFDemo.java code example to learn how to use exceptions when checking for the end of the file while reading from a binary file. - This method also throws IOExceptions. The IOExceptions may originate in the methods but must not be handled. Instead, they must be propagated to the calling code. 3. Method Largelnteger addLargelntegersFromFile(String) takes a text file name as a parameter. It reads an arbitrary number of strings of text from the file, converting them into Largelntegers as it reads. The Large Integers are added one by one to the running total with the help of add() method. The sum of all the Large Integers stored in the file as strings is then returned from the method. - The structure of the file may be imperfect. Some strings may contain corrupted data and will fail to be converted into Largelnteger. This must not interrupt the process of reading from the file. The corrupted string must be skipped over, and the next string must be read and converted. Use a try/catch block to catch and ignore LargelntegerNumberFormatException. - The sum of all numbers stored in the file may become too big to be stored in a Large Integer. In that case, a LargeIntegerOverflowException exception will be thrown by the add() method. If this happens, catch the exception and return a null value from the method. - This method also throws IOExceptions. The IOExceptions may originate in the methods but must not be handled. Instead, they must be propagated to the calling code.

Large Integers Part #1 Largelnteger Class An array can be used to store large integers, one digit at a time. For example, the integer 1234 could be stored in the array num by setting num[0] to 1, num[1] to 2, num[2] to 3, num[3] to 4. However, for this class implementation, you might find it more useful to store the digits backward; that is, place 4 in num[0], 3 in num[1], 2 in num[2], and 1 in num[3]. For the sake of simplicity, we will be storing and manipulating only with positive large inte

Read More

use Python In Minecraft, potions can be made and drank. When drank, they apply the corresponding…

In Minecraft, potions can be made and drank. When drank, they apply the corresponding potion effect to the player for some specified amount of time. "A Furious Cocktail" is the name of the advancement where a player has every potion effect applied at the same time. This is a challenging feat, as it takes time to drink each potion, and only one potion can be drank at a time. Suppose that in your inventory, there are N unique potions that have a time duration of t1,,tN seconds, respectively. Assuming that it takes T seconds to drink a potion, is it possible to have all N potion effects applied at the same time? Note that if one potion's effect ends at the same time you finish drinking another potion, the potions are not considered to be applied at the same time. Input The first line consists of 2 integers, 0<N<1000 and 1T10, the number of potions in your inventory and time in seconds it takes to drink each potion, respectively. The next N lines each consists of an integer 1ti106, the time duration of the i-th potion where i ranges from 1 to N. Output Output "YES" if it is possible to have all N potion effects applied at the same time, "NO" if otherwise.

In Minecraft, potions can be made and drank. When drank, they apply the corresponding potion effect to the player for some specified amount of time. “A Furious Cocktail” is the name of the advancement where a player has every potion effect applied at the same time. This is a challenging feat, as it takes time to drink each potion, and only one potion can be drank at a time. Suppose that in your inventory, there are N unique potions that have a time duration of t1,,tN seconds, respectively. Assum

Read More

– Three cats with names- Mia, Ruby and Snowy are playing Rock-Paper-Scissors. – Basic rules of the…

- Three cats with names- Mia, Ruby and Snowy are playing Rock-Paper-Scissors. - Basic rules of the game are: Rock beats scissors, scissors beat paper, and paper beats rock. - Each cat gains 3.5 points per win, loses a point per match lost, and gains 1.5 points if a match is drawn. - A total of 5 matches were played between Snowy and Mia. Snowy threw rock, paper, and scissors while Mia threw scissors, paper, and rock in the first three matches. In the last 2 matches, both Snowy and Mia threw rock. - Mia and Ruby played 3 matches in which Ruby threw rock three times while Mia threw paper, rock, and scissors. - 7 matches were played between Snowy and Ruby. Snowy threw rock, scissors, rock, paper, paper, rock, scissors while Ruby threw scissors, rock, scissors, scissors, rock, paper, scissors respectively. - Interpret the above data to display/fill the table on the next page. - Instructions and Hints: - Display the column Match Number using string data type. - Display table headings using cout in C++ - Display columns with headings Gesture using string data type. Use the information provided above to fill these columns for each cat. - Create 2-D arrays for columns-Won, Lost and Draw. You are required to enter the number of points, not the no. of wins, loses, or draws under these columns. Use for loops and if-else statements to fill the information under these columns. - Create a sum function to calculate Points (=sum of Win, loss and draw per match) for each cat. - Create a mean function to calculate "Average" for columns- Won, Lost, Draw and Points. - Calculate Winning probability using the following formula. WinningProbability=TotalnumberofOutcomesNumberoffavourableOutcomes100 - PS: Calculations for -Won, Lost, Drawn and Winning Probability should be done using for loops, if-else statements. Calculation under Points and Average should be done using functions for 2D arrays. You may call a function for 2D arrays with or without using pointers!

– Three cats with names- Mia, Ruby and Snowy are playing Rock-Paper-Scissors. – Basic rules of the game are: Rock beats scissors, scissors beat paper, and paper beats rock. – Each cat gains 3.5 points per win, loses a point per match lost, and gains 1.5 points if a match is drawn. – A total of 5 matches were played between Snowy and Mia. Snowy threw rock, paper, and scissors while Mia threw scissors, paper, and rock in the first three matches. In the last 2 matches, both Snowy and Mia threw rock

Read More