(b) Modify the program in Q3(a), with the following new rules: – Players will need to win 3 games…

(b) Modify the program in Q3(a), with the following new rules: - Players will need to win 3 games to become the overall winner. - Implement a penalty - for the player who skipped, entered an incorrect expression, or entered an expression that evaluated to the wrong result, will draw 2 random digits into their hand. - The player who loses the game will be awarded a "Skip" card in the next game. With the "Skip" card, the player can hit < Enter > to skip, without a penalty. - If not utilized, the "Skip" cards CANNOT be carried forward to the next game. Illustration of the "new" game on the left column, with the rules of the game explained on the right column: Enter player: Alan Enter player: Betty Enter player: Starting hand (number) of digits: 4 Let's play... Game 1 Round 1: Result 6 Betty's hand: [5,2,1,1] Enter expression: 5+1 Correct! Betty's hand: [2,1] Alan wins this game in 4 rounds!! Overall game score: Alan 1, Betty 0 Let's play... Game 2 Round 1: Result 5 Betty's hand: [3, 6, 5, 7, 'S'] Enter expression: Skipped with no penalty!! Betty's hand: [3,6,5,7] Alan's hand: [2,1,2,1] Enter expression: Skipped and 2 digits added to hand Alan's hand: [2,1,2,1,4,7] Betty wins this game in 5 rounds!! Overall game score: Alan 1, Betty 1 Let's play... Game 3 Round 1: Result 6 Betty's hand: [1, 2, 8, 7] Enter expression: 8-2 Correct! Betty's hand: [1, 7] Computer randomized the play sequence and will stay the same for every game/round End of game, if no overall winner, continue to play another game. Loser will be awarded a "Skip" card in the next game. "S" represents the "Skip" card awarded to Betty. No penalty for Betty as she has a "Skip" card. Hit < Enter > key to skip if cannot form an expression. In this case, the player who skipped will draw 2 random digits into their hand. End of game, if no overall winner, continue to play another game. Loser will be awarded a "Skip" card in the next game.

(b) Modify the program in Q3(a), with the following new rules: – Players will need to win 3 games to become the overall winner. – Implement a penalty – for the player who skipped, entered an incorrect expression, or entered an expression that evaluated to the wrong result, will draw 2 random digits into their hand. – The player who loses the game will be awarded a “Skip” card in the next game. With the “Skip” card, the player can hit < Enter > to skip, without a penalty. – If not utilized, the “

Read More

Euercise 1: Write a Python program that reads a floating point number and prints “zero” if the…

Exercise 1: Write a Python program that reads a floating-point number and prints "zero" if the number is zero. Otherwise, print "positive" or "negative". Add the following prefix "small" if the absolute value of the number is less than 1, or "large" if it exceeds 1,000,000. Exercise 2: Write a Python program that reads three numbers and prints "All the same" if they are all the same, "All different" if they are all different, and "neither" otherwise. Exercise 3: Write a Python program that displays the minimum of 3 numbers read from the keyboard. For example, if the user enters 458, 420, and 61, the output should be 420. You are not allowed to use the function min(). Exercise 4: Suppose x and y are variables, each of which contains a number. Write a Python program that sets y to the absolute value of x without calling the abs() function. Use an if statement. Exercise 5: Write a Python program that reads four angles values separated by spaces and prints if they could represent a triangle. Exercise 6: Write a program that reads three numbers and prints "increasing" if they are in increasing order, "decreasing" if they are in decreasing order, and "neither" otherwise. Here, "increasing" means "strictly increasing", with each value larger than its predecessor. The sequence 344 would not be considered increasing. Exercise 7: Write a Python program that receives two integers (numerator and denominator) from the user and calculates then displays the result of the division numerator/denominator. Make sure to display a message stating that division by zero is an illegal operation if the denominator is zero. Exercise 8: Write a Python program that receives the current temperature as input. If the temperature is 30 degrees or more, output a message telling the user to go swimming. Otherwise, if the temperature is 15 degrees or more, output a message to go running. Otherwise, stay inside. Exercise 9: Your health status depends on your Body Mass Index (BMI). BMI is a person's weight in kilograms or pounds divided by the square of height in meters or inches. The formula for BMI is weight in kilograms divided by height in meters squared. If height has been measured in centimeters, divide by 100 to convert this to meters. See below the BMI ranges. When using English measurements, pounds should be divided by inches squared. This should then be multiplied by 703 to convert from pounds per square inch to kg/m^2. Write a Python program that reads in your weight and your height, then displays your health status: Underweight, Healthy, Overweight, or Obese. Your program should accept both metric (kg, cm) or English units (lb, inches). Your program should test the validity of the input, that is, both weight and height are positive. BMI ranges: - Below 18.5: Underweight - 18.5-24.9: Healthy - 25.0-29.9: Overweight - 30.0 or higher: Obese.

Exercise 1: Write a Python program that reads a floating-point number and prints “zero” if the number is zero. Otherwise, print “positive” or “negative”. Add the following prefix “small” if the absolute value of the number is less than 1, or “large” if it exceeds 1,000,000. Exercise 2: Write a Python program that reads three numbers and prints “All the same” if they are all the same, “All different” if they are all different, and “neither” otherwise. Exercise 3: Write a Python program that displ

Read More

Create a cash register application for a fish and chips tuck shop. The application must have the…

Create a cash register application for a fish and chips tuck shop. The application must have the following controls: 1. Combo box - combo boxes for chips with small, medium, and large options and fish with options snoek and hake. 2. Check box - check box to either choose a cool drink or rolls, or both. 3. Quantity text field - text fields to specify the quantity of the product being bought. 4. Amounts text fields - text fields for total, amount paid, and change amount. NB. The user must make selections (chips, fish, cool drink, or roll) and specify the quantity. In the amount text fields, the user must only enter the amount paid, and the app must calculate the total price and the change amount. Product price list:

Create a cash register application for a fish and chips tuck shop. The application must have the following controls: 1. Combo box – combo boxes for chips with small, medium, and large options and fish with options snoek and hake. 2. Check box – check box to either choose a cool drink or rolls, or both. 3. Quantity text field – text fields to specify the quantity of the product being bought. 4. Amounts text fields – text fields for total, amount paid, and change amount. NB. The user must mak

Read More

4. Write a program that implements and uses a class called MyRectangle. Data items should include:…

Write a program that implements and uses a class called MyRectangle. Data items should include: length, width, color, and label. Define properties with appropriate accessor functions for each of the data items. Methods should include a default constructor that sets values to the empty string or zero, a constructor that allows the user to specify all values for the data items, a member method that computes and returns the area of the shape, and a member method called DisplayShape that outputs all the information (including the area via the ComputeArea method for the given rectangle in a reasonable format.

Write a program that implements and uses a class called MyRectangle. Data items should include: length, width, color, and label. Define properties with appropriate accessor functions for each of the data items. Methods should include a default constructor that sets values to the empty string or zero, a constructor that allows the user to specify all values for the data items, a member method that computes and returns the area of the shape, and a member method called DisplayShape that outputs a

Read More

5. Write a program that implements a class called MyTeam. Your class should have the following…

5. Write a program that implements a class called MyTeam. Your class should have the following private data items: Id (int), Name (string), Slogan (string), Wins (int), and Losses (int). You need to define properties with appropriate accessor functions for each of the data items. Methods should include a default constructor that sets values to the empty string or zero, a constructor that allows the user to specify all values for the data items, a member method called DisplayTeamInfo that outputs all the information for the given toy in a reasonable format. Challenge Problem: Code your set accessors to restrict all numeric fields (Id, Wins, Losses) to positive numbers. You can determine how you want to report/respond to the error. (25 pts) The code below is my suggestion for your Main() method for Program 22 static void Main(string[] args) { MyTeam myHitchhikers = new MyTeam(); myHitchhikers.Id = 42; myHitchhikers.Name = "Ford Prefect et. al."; myHitchhikers.Slogan = "Don't panic!"; myHitchhikers.Wins = 525; myHitchhikers.Losses = 42; Console.WriteLine("nTeam 1 Information"); myHitchhikers.DisplayTeamInfo(); MyTeam mykitties = new MyTeam(); Console.WriteLine("nTeall 2 Information"); mykitties.DisplayTeamInfo(); MyTeam myPatriots = new MyTeam(2023, "UC Patriots", "One Big Team", 42, 3); Console.WriteLine("nTeam 3 Information"); myPatriots.DisplayTeamInfo(); //This will test your Challenge Problem Settings if you attempted them Console.WriteLine("nTeam 4 Information"); MyTeam mywinners = new MyTeam(13, "Winners", "We like to win more than you do", -20, -35); } myllinners.DisplayTeamInfo();

5. Write a program that implements a class called MyTeam. Your class should have the following private data items: Id (int), Name (string), Slogan (string), Wins (int), and Losses (int). You need to define properties with appropriate accessor functions for each of the data items. Methods should include a default constructor that sets values to the empty string or zero, a constructor that allows the user to specify all values for the data items, a member method called DisplayTeamInfo that outputs

Read More

Write a Python program for an online MoonBucks coffee order. Coffee is sold by the pound, and the price per pound

Write a Python program for an online MoonBucks coffee order. Coffee is sold by the pound, and the price per pound depends upon the quantity ordered according to the table shown below. Partial pounds are not sold. Shipping is $1.00 per pound, but free for coffee orders over $150 before tax. The user must enter the number of pounds desired from the keyboard. The program will then display the cost of the coffee, the 7% sales tax, shipping charges (if any) and the total amount due. All four values should be displayed in currency format with the $ sign right up against the first digit. See SAMPLE OUTPUTS below. MoonBucks Coffee Company - Coffee Prices 40 pounds or more $7.50 per lb. 20 pounds or more $8.75 per lb. 10 pounds or more $10.00 per lb. 1 to 9 pounds $12.00 per lb. Start with a comment that includes your name and course number. Include pseudocode that describes all steps required to solve the problem. Employ variable names that describe the values they store and adhere to Python naming conventions. Include additional comments as needed to annotate your code. Use correct spelling and grammar. SAMPLE OUTPUT How many pounds are you ordering? 15 Cost of coffee $150.00 7% sales tax $10.50 Shipping fee $15.00 Total payable $175.50 SAMPLE OUTPUT How many pounds are you ordering? 50 Cost of coffee $375.00 7% sales tax $26.25 Shipping fee $0.00 Total payable $401.25

Write a Python program for an online MoonBucks coffee order. Coffee is sold by the pound, and the price per pound depends upon the quantity ordered according to the table shown below. Partial pounds are not sold. Shipping is $1.00 per pound, but free for coffee orders over $150 before tax. The user must enter the number of pounds desired from the keyboard. The program will then display the cost of the coffee, the 7% sales tax, shipping charges (if any) and the total amount due. All four values s

Read More

Create a new project called Lab9 and copy the given .java files into the src folder of this lab project folder. Refresh the project in Eclipse to show the provided files there.

Exercise 1 - Iterative vs. recursive methods 1. Create a new project called Lab9 and copy the given .java files into the src folder of this lab project folder. Refresh the project in Eclipse to show the provided files there. 2. Open FibonacciDemo.java and FactorialDemo.java and examine the code. Carefully read through the ifib() and rfib() methods in FibonacciDemo and ifact() and rfact() in FactorialDemo. Compare the iterative and recursive approaches in both classes. Why do the iterative methods require so many variables? What are the base cases of the recursive methods? 3. Run the program and when asked for numbers, enter5,10,15, and 20 . Write down the running times reported by the algorithm. Experiment with other numbers too but note that Factorial will not work for numbers over 25 as the long type will not be able to hold numbers larger than that. 4. In FibonacciDemo, modify the code to include a new variable called methodCalls2 that keeps track of the number of calls made to methodrfib()when the value of the parameternis 2 and prints it out in the main() method. Run the program and enter the value 40 . How many calls are made torfib()when the value of the parametern=2? Write down this result. 5. Why is the recursive algorithm for computing Fibonacci numbers so slow compared to the iterative algorithm? Does the value of methodCalls2 make sense with this rationale?

Exercise 1 – Iterative vs. recursive methods 1. Create a new project called Lab9 and copy the given .java files into the src folder of this lab project folder. Refresh the project in Eclipse to show the provided files there. 2. Open FibonacciDemo.java and FactorialDemo.java and examine the code. Carefully read through the ifib() and rfib() methods in FibonacciDemo and ifact() and rfact() in FactorialDemo. Compare the iterative and recursive approaches in both classes. Why do the iterative method

Read More