Friday, May 9, 2008

Java Practical 4

Java Practical 4 QNS 3 :

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package Practical4;

/**
*
* @author p0867519
*/

import javax.swing.*;

public class Practical4_Part1_Q3 {

public static void main(String[] args) {
String day;
String hour1;
double Hrate=0;

day = JOptionPane.showInputDialog("Enter day of work:");
hour1 = JOptionPane.showInputDialog("Enter no. of hour(s) worked:");
double hour = Double.parseDouble(hour1);

if (day.equals("MON") || day.equals("TUE") || day.equals("WED") ) {

if (hour<= 3) { Hrate = 60; } else if (hour > 3) {
Hrate = 70;
}
}

else if (day.equals("THUR") || day.equals("FRI")) {

if (hour <= 2){ Hrate = 70; } else if (hour > 2) {
Hrate = 80;
}
}

else if(day.equals("SAT") || day.equals("SUN")) {

Hrate = 90;
}

double payment = Hrate * hour ;

JOptionPane.showMessageDialog(null, "Day of Work \t : " + day +"\n" + "No.of hour(s)worked \t : " + hour + "\n" + "Hourly Rate\t: $ " + Hrate + "\n" + "Your Payment\t: $ " + payment);

}

}


Regards,
Alvin

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home