import java.util.Scanner;
public class ThreeFiveRevised
{
public static final double OVERTIME_PAY_RATE = 1.5;
public static final double REGULAR_PAY_RATE = 1.0;
public static void main(String[] args)
{
grabHourlyWages();
calculateMondayPay();
calculateTuesdayPay();
calculateWedneimport java.util.Scanner;
public class ThreeFiveRevised
{
public static final double OVERTIME_PAY_RATE = 1.5;
public static final double REGULAR_PAY_RATE = 1.0;
public static void main(String[] args)
{
grabHourlyWages();
calculateMondayPay();
calculateTuesdayPay();
calculateWednesdayPay();
calculateThursdayPay();
calculateFridayPay();
calculateTotalPay();
}
public static double grabHourlyWages()
{
Scanner reader = new Scanner(System.in);
System.out.println("Hourly wage");
double hourlyWage = reader.nextDouble();
double overtimeWage = hourlyWage * 1.5;
calculateMondayPay();
calculateTuesdayPay();
calculateWednesdayPay();
calculateThursdayPay();
calculateFridayPay();
return hourlyWage;
}
public static double calculateMondayPay()
{
double hourlyWage = grabHourlyWages();
double overtimeWage = grabHourlyWages();
Scanner reader = new Scanner(System.in);
System.out.println("Regular hours on Monday");
double regularMonHours = reader.nextDouble();
System.out.println("Overtime hours on Monday");
double overtimeMonHours = reader.nextDouble();
double mondayPay =
(hourlyWage * regularMonHours) + (overtimeWage * overtimeMonHours);
return mondayPay;
}
public static double calculateTuesdayPay()
{
double hourlyWage = grabHourlyWages();
double overtimeWage = grabHourlyWages();
Scanner reader = new Scanner(System.in);
System.out.println("Regular hours on Tuesday");
double regularTuesHours = reader.nextDouble();
System.out.println("Overtime hours on Tuesday");
double overtimeTuesHours = reader.nextDouble();
double tuesdayPay =
(hourlyWage * regularTuesHours) + (overtimeWage * overtimeTuesHours);
return tuesdayPay;
}
public static double calculateWednesdayPay()
{
double hourlyWage = grabHourlyWages();
double overtimeWage = grabHourlyWages();
Scanner reader = new Scanner(System.in);
System.out.println("Regular hours on Wednesday");
double regularWedHours = reader.nextDouble();
System.out.println("Overtime hours on Wednesday");
double overtimeWedHours = reader.nextDouble();
double wednesdayPay =
(hourlyWage * regularWedHours) + (overtimeWage * overtimeWedHours);
return wednesdayPay;
}
public static double calculateThursdayPay()
{
double hourlyWage = grabHourlyWages();
double overtimeWage = grabHourlyWages();
Scanner reader = new Scanner(System.in);
System.out.println("Regular hours on Thursday");
double regularThursHours = reader.nextDouble();
System.out.println("Overtime hours on Thursday");
double overtimeThursHours = reader.nextDouble();
double thursdayPay =
(hourlyWage * regularThursHours) + (overtimeWage * overtimeThursHours);
return thursdayPay;
}
public static double calculateFridayPay()
{
double hourlyWage = grabHourlyWages();
double overtimeWage = grabHourlyWages();
Scanner reader = new Scanner(System.in);
System.out.println("Regular hours on Friday");
double regularFriHours = reader.nextDouble();
System.out.println("Overtime hours on Friday");
double overtimeFriHours = reader.nextDouble();
double fridayPay =
(hourlyWage * regularFriHours) + (overtimeWage * overtimeFriHours);
return fridayPay;
}
public static double calculateTotalPay()
{
double mondayPay = calculateMondayPay();
double tuesdayPay = calculateTuesdayPay();
double wednesdayPay = calculateWednesdayPay();
double thursdayPay = calculateThursdayPay();
double fridayPay = calculateFridayPay();
double TotalPay =
mondayPay + tuesdayPay + wednesdayPay + thursdayPay + fridayPay;
return TotalPay;
}
}
sdayPay();
calculateThursdayPay();
calculateFridayPay();
calculateTotalPay();
}
public static double grabHourlyWages()
{
Scanner reader = new Scanner(System.in);
System.out.println("Hourly wage");
double hourlyWage = reader.nextDouble();
double overtimeWage = hourlyWage * 1.5;
calculateMondayPay();
calculateTuesdayPay();
calculateWednesdayPay();
calculateThursdayPay();
calculateFridayPay();
return hourlyWage;
}
public static double calculateMondayPay()
{
double hourlyWage = grabHourlyWages();
double overtimeWage = grabHourlyWages();
Scanner reader = new Scanner(System.in);
System.out.println("Regular hours on Monday");
double regularMonHours = reader.nextDouble();
System.out.println("Overtime hours on Monday");
double overtimeMonHours = reader.nextDouble();
double mondayPay =
(hourlyWage * regularMonHours) + (overtimeWage * overtimeMonHours);
return mondayPay;
}
public static double calculateTuesdayPay()
{
double hourlyWage = grabHourlyWages();
double overtimeWage = grabHourlyWages();
Scanner reader = new Scanner(System.in);
System.out.println("Regular hours on Tuesday");
double regularTuesHours = reader.nextDouble();
System.out.println("Overtime hours on Tuesday");
double overtimeTuesHours = reader.nextDouble();
double tuesdayPay =
(hourlyWage * regularTuesHours) + (overtimeWage * overtimeTuesHours);
return tuesdayPay;
}
public static double calculateWednesdayPay()
{
double hourlyWage = grabHourlyWages();
double overtimeWage = grabHourlyWages();
Scanner reader = new Scanner(System.in);
System.out.println("Regular hours on Wednesday");
double regularWedHours = reader.nextDouble();
System.out.println("Overtime hours on Wednesday");
double overtimeWedHours = reader.nextDouble();
double wednesdayPay =
(hourlyWage * regularWedHours) + (overtimeWage * overtimeWedHours);
return wednesdayPay;
}
public static double calculateThursdayPay()
{
double hourlyWage = grabHourlyWages();
double overtimeWage = grabHourlyWages();
Scanner reader = new Scanner(System.in);
System.out.println("Regular hours on Thursday");
double regularThursHours = reader.nextDouble();
System.out.println("Overtime hours on Thursday");
double overtimeThursHours = reader.nextDouble();
double thursdayPay =
(hourlyWage * regularThursHours) + (overtimeWage * overtimeThursHours);
return thursdayPay;
}
public static double calculateFridayPay()
{
double hourlyWage = grabHourlyWages();
double overtimeWage = grabHourlyWages();
Scanner reader = new Scanner(System.in);
System.out.println("Regular hours on Friday");
double regularFriHours = reader.nextDouble();
System.out.println("Overtime hours on Friday");
double overtimeFriHours = reader.nextDouble();
double fridayPay =
(hourlyWage * regularFriHours) + (overtimeWage * overtimeFriHours);
return fridayPay;
}
public static double calculateTotalPay()
{
double mondayPay = calculateMondayPay();
double tuesdayPay = calculateTuesdayPay();
double wednesdayPay = calculateWednesdayPay();
double thursdayPay = calculateThursdayPay();
double fridayPay = calculateFridayPay();
double TotalPay =
mondayPay + tuesdayPay + wednesdayPay + thursdayPay + fridayPay;
return TotalPay;
}
}
Мое задание для класса - взять почасовую заработную плату пользователя, количество обычных часов и сверхурочных часов, отработанных на каждый отдельный день с понедельника по пятницу.Затем рассчитайте общую оплату.Они только что представили методы, поэтому, хотя вы могли просто сделать это в методе main, мой учитель специально сказал нам, что нам нужно выполнять вычисления для каждого дня в соответствующем методе и использовать метод main только в качестве места для вызова других методов.и не использовать его для выполнения каких-либо расчетов.
Я остановился, потому что я не уверен, что делать с этого момента.Я создал свои пять методов для каждого дня рабочей недели, и я создал свой метод для расчетов.Дело в том, как мне настроить метод?Я выполнил
CalculayTotalPay (mondayPay, tuesdayPay, wednesdayPay, thursdayPay, fridayPay)
Однако я не могу отправить информацию от каждого из пяти методов, потому что когда я вхожу в метод mondayPay, яЯ не могу отправить только один аргумент, так как метод calcTOtalPay принимает 5 аргументов, и я не могу отправить аргументы отдельно, потому что не знаю как.Помогите ..?
очень плохо знакомы с Java, так что извините, если мой вопрос глуп, единственная причина, по которой он не был предложен в качестве предложенного ответа, вероятно, потому что я не знал, как сформулировать вопрос.