Question

e. Code a while loop that determines and prints the winnings for the Daytona 500 depending...

e. Code a while loop that determines and prints the winnings for the Daytona 500 depending upon the position after the finish-line: 1st, 2nd, or 3rd.

  1. Assume the input variable for the Scanner class, position and prizeMoney variables are already declared.
  2. Declare noWinners variable, and initialize it to the number of winners.   
  3. Declare a counter-control variable for the while loop, and initialize it.
  4. When the loop is entered, prompt: The driver crossed the finish line in which place?
  5. Insert the if-else structure from b into the while loop, and include code from .
  6. Print the following according to the position number where the $Z,ZZZ,ZZ9 is the amount of the prize money. The Z’s suppress the printing of leading zeroes and the 9 denotes printing of any number from 0-9:
    • 1st place: You’re the first place winner and you get $Z,ZZZ,ZZ9!
    • 2nd place: You’re the second place winner and you get $Z,ZZZ,ZZ9!
    • 3rd place: You’re the third place winner and you get $Z,ZZZ,ZZ9!

the language this should be in is java

i am a bit lost on where to begin...

my b loop is

If (position == 1)

{

prizeMoney = $1,581,453;

}

else

{

if (position == 2){

prizeMoney = $1,157,470;

}

else {

if (position == 3){

prizeMoney = 857,245;

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1
import java.util.Scanner;

//Main class
public class Main {
    public static void main(String[] args) {
        double prizeMoney;
        int position;
        Scanner scan = new Scanner(System.in);

        int noWinners = 3, count = 0;
        while (count < noWinners) {
            System.out.print("The driver crossed the finish line in which place?: ");
            position = scan.nextInt();
            if (position == 1) {
                prizeMoney = 1_581_453;
                System.out.println("You’re the first place winner and you get $" + prizeMoney + "!");
            } else {
                if (position == 2) {
                    prizeMoney = 1_157_470;
                    System.out.println("You’re the second place winner and you get $" + prizeMoney + "!");
                } else {
                    if (position == 3) {
                        prizeMoney = 857_245;
                        System.out.println("You’re the third place winner and you get $" + prizeMoney + "!");
                    }
                }
            }
            count++;
        }
    }
}

OUTPUT:

FOR ANY HELP DROP A COMMENT

Add a comment
Know the answer?
Add Answer to:
e. Code a while loop that determines and prints the winnings for the Daytona 500 depending...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please code this in java: The purpose of this assignment is to: Read double data in...

    Please code this in java: The purpose of this assignment is to: Read double data in to a TreeSet where each datum inserted is Math.abs(datum) (i.e., no negative values are inserted). NOTE: This will (i) sort the data placed into the TreeSet, and, (ii) remove duplicate values since no duplicates are allowed (i.e., duplicates will not be inserted). Create a list iterator. Iterate backwards through the TreeSet (i.e., from the largest value to the smallest) outputting all elements * -1.0....

  • import java.util.*; /** Description: This program determines the average of a list of (nonnegative) exam scores....

    import java.util.*; /** Description: This program determines the average of a list of (nonnegative) exam scores. Repeats for more exams until the user says to stop. Input: Numbers, sum, answer Output: Displays program description Displays instruction for user Displays average Algorithm: 1. START 2. Declare variables sum, numberOf Students, nextNumber, answer 3. Display welcome message and program description 4. DOWHILE user wants to continue 5. Display instructions on how to use the program 6. Inititalize sum and number of student...

  • Please help me edit my code so it looks a little different but produces the same...

    Please help me edit my code so it looks a little different but produces the same output. Me and classmate did the assignment correctly but are afraid of plagarism. Here is my code. /** * @(#) * @author * @version 1.00 6/25/2017 3:00 PM * Program Purpose: Code a program that computes sales revenue * to-date to determine the status of the company’s * sales revenue and whether a year end bonus is in store for the employees. */ import...

  • In this code I have 3 racers running, dog, cat, and tigger. Dog and tigger are...

    In this code I have 3 racers running, dog, cat, and tigger. Dog and tigger are at random speeds and the cat controlled by pressing a and s to move. Please just edit the code to include part E which is when one of the three racers reaches the finish line announce the winner. import java.awt.Color; import java.util.Random; public class RaceTrack{    public static void main(String[] args) {        //        EZ.initialize(680,680);        //        int...

  • Using Swift playground and / or the command line for macOS (open Xcode, create a new...

    Using Swift playground and / or the command line for macOS (open Xcode, create a new Xcode project, macOS, command line tool), practice the following exercises: Exercise: Swift Variables Declare 2 variables/constants with some random values and any name of your choice Considering these 2 variables, one as a value of PI and other as a radius of circle, find the area of circle Print the area of circle Declare a string variable explicitly with value “Northeastern”. Declare a string...

  • Could anyone help add to my python code? I now need to calculate the mean and...

    Could anyone help add to my python code? I now need to calculate the mean and median. In this programming assignment you are to extend the program you wrote for Number Stats to determine the median and mode of the numbers read from the file. You are to create a program called numstat2.py that reads a series of integer numbers from a file and determines and displays the following: The name of the file. The sum of the numbers. The...

  • In this project, you will write a complete program that allows the user to play a...

    In this project, you will write a complete program that allows the user to play a game of Mastermind against the computer. A Mastermind game has the following steps: 1. The codebreaker is prompted to enter two integers: the code length n, and the range of digits m. 2. The codemaker selects a code: a random sequence of n digits, each of which is in the range [0,m-1]. 3. The codebreaker is prompted to enter a guess, an n-digit sequence....

  • Complete a program In C#: some code is included, you edit the areas that have not...

    Complete a program In C#: some code is included, you edit the areas that have not been filled. For your C# program you will complete code that plays the War card game. In this game, the deck of cards is evenly divided among two players. The players are not allowed to look at the cards in their hand. On each round of the game, both players lay down the top card from their hand. The player with the higher value...

  • Lab 5.1 C++ Utilizing the code from Lab 4.2, replace your Cargo class with a new...

    Lab 5.1 C++ Utilizing the code from Lab 4.2, replace your Cargo class with a new base class. This will be the base for two classes created through inheritance. The Cargo class will need to have virtual functions in order to have them redefined in the child classes. You will be able to use many parts of the new Cargo class in the child classes since they will have the same arguments/parameters and the same functionality. Child class one will...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT