Compute gross as hours times rate

Assignment Help C/C++ Programming
Reference no: EM131863296

Create a payroll program. Enter Name, Hours and rate. Compute gross as Hours times Rate. Display Name, Hours Rate and Gross. Use Scanner class for your input and JOption as well as System.out.println for your output.

I have this code but am not sure why JOptionPane does not work

import java.util.Scanner;

import javax.swing.JOptionPane;

public class PayrollProg

{

  public static void main(String[] args)

  {

  Scanner input = new Scanner(System.in);

  double hourlyRate;

  double hoursWorked;

  double grossPay;

  System.out.print("Employee name: ");

  String employeeName = input.nextLine();

  System.out.printf("Enter hourly rate for %s: $", employeeName);

  hourlyRate = input.nextDouble();

  while (hourlyRate < 0.00)

  {

  System.out.print("Please only enter positive numbers: $");

  hourlyRate = input.nextDouble();

  }

  System.out.printf("Total hours worked: ");

  hoursWorked = input.nextDouble();

  while (hoursWorked < 0.00)

  {

  System.out.print("Please only enter positive numbers: ");

  hoursWorked = input.nextDouble();

  }

  grossPay = hourlyRate * hoursWorked;

  System.out.printf("Gross Pay: $%.2fn", grossPay);

  System.out.println();

  }

  {

  JOptionPane.showMessageDialog (null, "The gross pay for %s is ", grossPay);

  }

}

Reference no: EM131863296

Questions Cloud

Image that two programmers were arguing : Image that two programmers were arguing about the use of the for...loop and the do...while() loop. One programmer stated that in a Java program
Bond just paid coupon payment-has exactly two years maturity : The bond just paid a coupon payment and has exactly two years until maturity.. What is the price of the bond ?
Break the string into substrings : A program that reads a 4-bit binary number from the keyboard as a string and then converts it into decimal. For example, if the input is 1100,
Experienced some difficulties financing : The Bigshot Inc company has target current ratio of 2.0 but has experienced some difficulties financing its expanding sales in the past few months.
Compute gross as hours times rate : Compute gross as Hours times Rate. Display Name, Hours Rate and Gross. Use Scanner class for your input and JOption as well as System.out.println
How human resources are handled at the company : Think about how human resources are handled at the company you work for, or one you have worked for in the past. In the discussion thread.
Single command-line argument : How would you go about writing a C program that takes a single command-line argument, the name of a file.The program reads this file
What is company weighted average cost of capital : The company stock has a beta of 1.5 and the company's marginal tax rate is 35%. What is the company's weighted average cost of capital?
How many miles you need to drive on a four day rental : How many miles you need to drive on a four day rental so that the cost of the two alternatives would be same?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a program to convert miles to kilometers

Write a program to convert miles to kilometers. (Recall that 1 mi = 1.6093440 km.) Write a program to convert pounds to kilograms. (Recall that 1 kg = 2.205 lb.) Write a program to compute the area of A of a circle with radius r.

  Write a program that simulates the dial of a phone number

Write a program that simulates the dial of a phone number. The program will accept a phone number as input, and it will acknowledge the call by either writing an error message or the 8 digit phone number to the console window. The phone number may..

  Calculate the average of 5 test scores, then numbers entered

Write a new program in pseudo-code, it should input and calculate the average of 5 test scores, then numbers entered.

  Would the given code be legal for resolving the problem

Suppose you want to use the std namespace for several definitions in the program. Would the following code be legal for resolving the problem? If not, why not?

  Write a switch-case programming for calculation

How to use C++ to write a switch-case programming for calculation? Test the program for a wide range of possible inputs including division by zero and square root of negative values.

  Evaluate the tip amount that should be added

Write a program that will be used to evaluate the tip amount that should be added to a restaurant charge. Allow the user to input the total, before taxes and the tip percentage (15% or 20%).

  What is the :: called in c++

What is the :: called in C++ when used like this std::endl; In my main file, what line of code prevents me from having to put std before every endl

  In psuedocode, design an application

In psuedocode, design an application that has an array of at least 20 integers. It should call a module that uses the sequential search algorithm to locate one of the values

  Execute tests and repetitions

Read data from standard input and store them in an array, Execute tests and repetitions

  Monkey business, a local zoo

Monkey Business, a local zoo, wants to keep track of how many pounds of food each of its three monkeys eats each day during a typical week. Write a program that stores this information in a two-dimensional 3 7 array, where each row represents a di..

  Write a function named short_path

Write a function named 'short_path' which has two input parameters {M, N} and one output parameter T.

  Implement function types that takes no input

Implement function types that takes no input, declares 3 variables of type char, 3 of type short, 3 of type int, and 3 of type double.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd