Ask Question
9 September, 06:46

1. Copy the file Pay. java (see Code Listing 1.1) from the Student CD or as directed by your instructor. 2. Open the file in your Java Integrated Development Environment (IDE) or a text editor as directed by your instructor. Examine the file, and compare it with the detailed version of the pseudocode in step number 3, section 1.6 of the textbook. Notice that the pseudocode does not include every line of code. The program code includes identifier declarations and a statement that is needed to enable Java to read from the keyboard. These are not part of actually completing the task of calculating pay, so they are not included in the pseudocode. The only important difference between the example pseudocode and the Java code is in the calculation. Below is the detailed pseudocode from the example, but without the calculation part. You need to fill in lines that tell in English what the calculation part of Pay. java is doing.

+2
Answers (1)
  1. 9 September, 06:47
    0
    Code Listing 1.1 (Pay. java)

    import java. util. Scanner; / / Needed for the Scanner class

    /**

    This program calculates the user's gross pay.

    */

    public class Pay

    {

    public static void main (String[] args)

    {

    / / Create a Scanner object to read from the keyboard. Scanner keyboard = new Scanner (System. in);

    / / Identifier declarations

    double hours; / / Number of hours worked

    double rate; / / Hourly pay rate double pay; / / Gross pay

    / / Display prompts and get input. System. out. print ("How many hours did you work? "); hours = keyboard. nextDouble ();

    System. out. print ("How much are you paid per hour? ");

    rate = keyboard. nextDouble ();

    / / Perform the calculations. if (hours < = 40)

    pay = hours * rate;

    else

    pay = (hours - 40) * (1.5 * rate) + 40 * rate;

    / / Display results. System. out. println ("You earned $" + pay);

    }

    }

    Code Listing 1.2 (SalesTax. java)

    import java. util. Scanner; / / Needed for the Scanner class

    /**

    This program calculates the total price which includes

    sales tax.

    */

    public class SalesTax

    {

    public static void main (String[] args)

    {

    / / Identifier declarations final double TAX_RATE = 0.055; double price;

    double tax

    double total; String item;

    / / Create a Scanner object to read from the keyboard. Scanner keyboard = new Scanner (System. in);

    / / Display prompts and get input. System. out. print ("Item description: "); item = keyboard. nextLine (); System. out. print ("Item price: $");

    price = keyboard. nextDouble ();

    / / Perform the calculations. tax = price + TAX_RATE;

    totl = price * tax;

    / / Display the results. System. out. print (item + " $"); System. out. println (price); System. out. print ("Tax $"); System. out. println (tax); System. out. print ("Total $"); System. out. println (total);

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “1. Copy the file Pay. java (see Code Listing 1.1) from the Student CD or as directed by your instructor. 2. Open the file in your Java ...” in 📗 Engineering if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers