1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
True [87]
3 years ago
13

// Program prompts a user for name, hours worked,// and hourly pay rate// then computes gross pay and displays the name and gros

s pay// Modify the program to use four methods named// getName(), getHours(), getPayRate(), and computeGross()
Computers and Technology
1 answer:
Elza [17]3 years ago
7 0

Answer:

import java.util.Scanner;

public class num3 {

   public static void main(String[] args) {

       // Calling ComputeGross pay and getName

       System.out.println("Gross pay is for "+getName()+" is "+computGross());

   }

   // The method getName returns a string

   public static String getName(){

       System.out.println("Enter your name");

       Scanner in = new Scanner(System.in);

       String name = in.nextLine();

       return name;

   }

   //method getHours returns an int

   public static int getHours(){

       System.out.println("Enter your hours");

       Scanner in = new Scanner(System.in);

       int hours = in.nextInt();

       return hours;

   }

   //Method getPayRate returns a double

   public static double getPayRate(){

       System.out.println("Enter your pay rate");

       Scanner in = new Scanner(System.in);

       double payRate = in.nextDouble();

       return payRate;

   }

   //Calculates and returns the gross pay by multiplying payrate by hours worked

   public static double computGross(){

       double gross = getHours()*getPayRate();

       return gross;

   }

}

Explanation:

  • This is solved in Java programming language
  • Pay detailed attention to the comments in the solution
  • A main method is created where getName and computGross are called inside the output statement
  • Observe that the method computGross calls getHours and getPayRate within itself
You might be interested in
1. Write a while loop that lets the user enter a number. The number should be multiplied by 10, and the result assigned to a var
shutvik [7]

Answer:

import java.util.Scanner;

public class num6 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       int product=0;

       do{

           System.out.println("Enter a number");

           int num = in.nextInt();

           product = num*10;

           System.out.println("The product is " + product);

       }while (product<100);

  }

}

Explanation:

In the Java program above, The user will be prompted to enter a number.

The number is multiplied by 10 and assigned to a variable called product.

A do....while loop has been implemented to check the variable product

As long as this variable is less than 10, the user will be prompted to enter another number.

3 0
3 years ago
What is common for all machines​
Fed [463]

Answer:

the question is a bit vague, but all machines exist to serve a purpose, or to do or accomplish a certain task.

6 0
3 years ago
Read 2 more answers
It is possible to make the document larger for viewing small text. <br> True or False
kirill [66]
I believe your answer is true
5 0
4 years ago
Read 2 more answers
Which of the following statements is not true about report styles?
Lina20 [59]

Answer:

The answer to the following question is the option "C".

Explanation:

In computer science, Report is a document that displays data in a standardized format. We can summarize the report orally but the complete reports are always given in documents. In report styles, we can select controls for formatting sources, select controls for the formatting of citations and it does not control the overall formatting of the report. So the incorrect statement to this question is "Use the Page Setup tab to choose a report style for your document".

3 0
4 years ago
How do you add a section break that would start the new section on the same page?
Maksim231197 [3]
Leave a line and that will make a section break
8 0
4 years ago
Read 2 more answers
Other questions:
  • Type the correct answer in the box. Spell all words correctly.
    12·1 answer
  • You cannot legally install macOS on a PC that originally came with Windows<br> True or false
    13·2 answers
  • c++ Project 6: Buoyancy. Buoyancy is the ability of an object to float. Archimedes’ principle states that the buoyant force is e
    13·1 answer
  • What will you see on the next line?
    6·2 answers
  • A _______ read inputs the first data item from a file. It typically appears immediately before the loop that processes the data
    5·1 answer
  • Brian is a computer engineer who writes security software for a banking system. The
    13·1 answer
  • ANSWER ASAP! 50 POINTS!!!!
    10·2 answers
  • 1. In platform construction, wall-framing members include sole plates,
    15·2 answers
  • You need a(n) _____ to play an mp3 audio file on a desktop or laptop computer
    15·1 answer
  • Use a slicer to filter the data in this table to show only rows where the Category value is Coffee or Meals
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!