The document outlines 5 programming assignments involving loops and conditional statements in Java:
1. A program to calculate parking fees based on hours parked.
2. A program to calculate total amount due based on commodity code, quantity, and price.
3. A program to reverse a number and calculate the sum of its digits.
4. A program to calculate the sum of a series until it exceeds 3.1.
5. A program to calculate and display Y values using the equation Y=2+4X-X for X from 1 to 20.
The document outlines 5 programming assignments involving loops and conditional statements in Java:
1. A program to calculate parking fees based on hours parked.
2. A program to calculate total amount due based on commodity code, quantity, and price.
3. A program to reverse a number and calculate the sum of its digits.
4. A program to calculate the sum of a series until it exceeds 3.1.
5. A program to calculate and display Y values using the equation Y=2+4X-X for X from 1 to 20.
The document outlines 5 programming assignments involving loops and conditional statements in Java:
1. A program to calculate parking fees based on hours parked.
2. A program to calculate total amount due based on commodity code, quantity, and price.
3. A program to reverse a number and calculate the sum of its digits.
4. A program to calculate the sum of a series until it exceeds 3.1.
5. A program to calculate and display Y values using the equation Y=2+4X-X for X from 1 to 20.
The document outlines 5 programming assignments involving loops and conditional statements in Java:
1. A program to calculate parking fees based on hours parked.
2. A program to calculate total amount due based on commodity code, quantity, and price.
3. A program to reverse a number and calculate the sum of its digits.
4. A program to calculate the sum of a series until it exceeds 3.1.
5. A program to calculate and display Y values using the equation Y=2+4X-X for X from 1 to 20.
Download as DOC, PDF, TXT or read online from Scribd
Download as doc, pdf, or txt
You are on page 1of 2
1
Final Requirement:
1. ParkingFee.java (Use if 20pts)
Parking charge per hour at SMBC underground parking is as follows: P 35.00 - minimum charge for 4 hours parking or less, P 15.00/hr. - additional charge in excess of 4 hours parking, P 250.00 - maximum charge. Create a java program that reads the number of hours a vehicle was parked. Calculate and output the parking charge. (Note: Inputs should be integers only) Depicted below are sample outputs when the program is executed (the items in red bold characters are inputted by the user, while the items in blue bold characters are calculated and outputted by the program):
Enter number of hours: 3 Enter number of hours: 6 Enter number of hours: 23
Parking Fee: P 35 Parking Fee: P 65 Parking Fee: P 250
2. CommodityCode.java (Use switch)
A certain store has the following scheme: Commodity Code: A - commodities are discounted by 15% B - commodities are taxed by 12% C - commodities are charged as priced Create a java program that reads a commodity code, quantity of the commodities bought and the unit price. The program should output the amount to be paid by the customer. Depicted below are sample outputs when the program is executed (the items in red bold characters are inputted by the user, while the items in blue bold characters are calculated and outputted by the program):
Enter commodity code: E Enter commodity code: A
Invalid Code Enter quantity of commodity: 2 Enter unit price: 53.25 Amount to be paid is P90.53
Enter commodity code: B Enter commodity code: A
Enter quantity of commodity: 2 Enter quantity of commodity: 2 Enter unit price: 53.25 Enter unit price: 53.25 Amount to be paid is P119.28 Amount to be paid is P106.50
3. Reverse.java – (Use the do-while Loop 20pts)
Create a java program that reads a number (NUM) and determine its reverse by using the division and remainder/modulo operators. If the last digit is zero, replace it with a one(1) before reversing the number. Output also the sum of all the digits. Depicted below are sample outputs when the program is executed (the items in red bold characters are inputted by the user, while the items in blue bold characters are calculated and outputted by the program):
Input a number: 1034 Input a number: 241620
The reversed order is 4301 The reversed order is 126142 The sum is 8 The sum is 16 2
4. Series1.java (Use the while Loop 20pts)
The value of S is computed from the formula: S = 1/1 + 1/2 + 1/3 + 1/4 + 1/5 + … + 1/N Without using a user-defined method, create a program to output the number of terms required and the value of S before S exceeds 3.1. Example: 1st term: S = 1; 2nd term: S = 1 + 1/2 = 1.5; 3rd term: S = 1 + 1/2 + 1/3 = 1.8333; 4th term: S = 1 + 1/2 + 1/3 + 1/4 = 2.08333; 5th term: S = 1 + 1/2 + 1/3 + 1/4 + 1/5 = 2.2833; ... nth term: S = ? Depicted below is a sample output when the program is executed:
5. Equation.java - (Use the for Loop 20pts)
Using the equation Y=2+4X-X, create a java program that will compute and display the values of Y for the values of X from 1 to 20 in increments of 1 without using an array. Depicted below is a sample output when the program is executed: