1. Write a Java class that prompts a student for the number of credit hours in which the student is enrolled, and the amount of money spent of books. Display, with full explanation, the student’s total fees. The total is Php 300 per credit hour, plus the amount for books, plus a Php 500 athletic fee.
SOURCE CODE: import javax.swing.JOptionPane; public class JStrucSeqProb1
{
public static void main(String[]args) { String numCreditHours, BookAmt; double credithours , credithoursamt, bookamt, atlfee, total;
numCreditHours = JOptionPane.showInputDialog(null, "Enter the number of your Credit Hours\n(Php300/Credit Hours): ", "Credit Hours", JOptionPane.PLAIN_MESSAGE); BookAmt = JOptionPane.showInputDialog(null, "Enter the amount of Book Spent: ", "Book Amount", JOptionPane.PLAIN_MESSAGE);
//converting String to Integer credithours = Double.parseDouble(numCreditHours); bookamt = Double.parseDouble(BookAmt); atlfee = 500; //computation credithoursamt = credithours * 300; total = credithoursamt + bookamt + atlfee;
JOptionPane.showMessageDialog(null, "Php300/Credit Hours Amount: Php" + credithoursamt + "\nBook Amount: Php" + bookamt + "\nAthletic Fee: Php" + atlfee + "\n\nTotal Amount: Php" + total, "Results", JOptionPane.INFORMATION_MESSAGE); }
}
OUTPUT LAYOUT: Fig.1 Fig.2 Fig.3
2. Write a class that accepts a user’s hourly rate of pay and the number of hours worked. Display the user’s gross pay, the withholding tax (15% of gross pay), and the net pay (gross pay-withholding).
SOURCE CODE: import javax.swing.JOptionPane; public class JStrucSeqProb2
{
public static void main(String[]args) { String numHours; double hours, hrsamt, gross, taxpercent, taxamt, net;
numHours = JOptionPane.showInputDialog(null, "Enter the number of hours worked: ", "Hours Worked", JOptionPane.PLAIN_MESSAGE);
hours = Double.parseDouble(numHours);