Spaces:
Running
Running
| ''' | |
| Write a program that asks the user to enter the number of working days (integer) and the daily wage (float). | |
| The program calculates the user's total salary based on this information. | |
| If there are more than 5 working days, the total salary will be increased by 20%. | |
| However, if there are more than 10 working days, the increase in the total salary is 50%. | |
| Example output: | |
| Workdays: 11 | |
| Daily salary: 8.50 | |
| Total salary: 140.25 | |
| ''' | |
| import java.util.Random; | |
| import java.util.Scanner; | |
| public class Test{ | |
| public static void main(String[] args){ | |
| final Random r = new Random(); | |
| Scanner reader = new Scanner(System.in); | |
| System.out.print("Workdays: "); | |
| int days = Integer.valueOf(reader.nextLine()); | |
| System.out.print("Daily salary: "); | |
| double dailysal = Double.valueOf(reader.nextLine()); | |
| double totalsal = days * dailysal; | |
| if (days>10) { | |
| totalsal*=1.5; | |
| } | |
| else if (days>5) { | |
| totalsal*=1.2; | |
| } | |
| else { | |
| totalsal=totalsal; | |
| } | |
| System.out.println("Total salary: "+totalsal); | |
| } | |
| } | |
| ''' | |
| Testing with inputs 2, 10.0 | |
| Workdays: 2 | |
| Daily salary: 10.0 | |
| Total salary: 20.0 | |
| Testing with inputs 9, 5 | |
| Workdays: 9 | |
| Daily salary: 5 | |
| Total salary: 54.0 | |
| Testing with inputs 11, 8.50 | |
| Workdays: 11 | |
| Daily salary: 8.50 | |
| Total salary: 140.25 | |
| Testing with inputs 17, 10.0 | |
| Workdays: 17 | |
| Daily salary: 10.0 | |
| Total salary: 255.0 | |
| ''' |