| | Programming (Simple Computation) | |
|
| Author | Message |
|---|
Admin Admin

Posts: 67 Join date: 2009-11-24 Age: 20 Location: Philippines
 | Subject: Programming (Simple Computation) Sat Nov 28, 2009 2:09 am | |
| public class do_while { public static void main(String[] args) { int Ctr=1; do { System.out.println(Ctr); Ctr++; }while(Ctr%2==1); } } |
|
 | |
Admin Admin

Posts: 67 Join date: 2009-11-24 Age: 20 Location: Philippines
 | Subject: Programming (if else) Sat Nov 28, 2009 2:09 am | |
| public class if_else{ public static void main(String args[]){ int x=2; System.out.println("Value is:"+x); if(x%2==0)System.out.println("Value is an even number"); else{ System.out.println("Value is an odd number."); } } } |
|
 | |
Admin Admin

Posts: 67 Join date: 2009-11-24 Age: 20 Location: Philippines
 | Subject: Programming (WorkHours) Sat Nov 28, 2009 2:11 am | |
| import java.io.*; public class LabEx4_No2{ public static InputStreamReader reader = new InputStreamReader(System.in); public static BufferedReader input = new BufferedReader(reader); public static void main(String args[]) throws Exception { int rate=35, hour=0, hours=0; double overtimeRate=0, overtime, overHour=0, normalpay=0, totalPay=0; int choice=0,start=1; while(start==1){ System.out.println("Please select a number"); System.out.println("1: Hour is less than 40:"); System.out.println("2: Hour is equal 40:"); System.out.println("3: Hour is greater than 40:"); System.out.println("ENTER YOUR CHOICE:"); choice=Integer.parseInt(input.readLine()); switch(choice) { case 1: System.out.println("Enter hours:"); hour=Integer.parseInt(input.readLine()); if(hour<40){ hours=hour*rate; System.out.println("Your normal pay is:"+hours); overtime=hour-40; overtime=overtime*overtimeRate*40; System.out.println("Your overtime pay is:"+overtime); totalPay=hours + overtime; System.out.println("Your total pay is:"+totalPay); break; } case 2: System.out.println("Enter hours:"); hour=Integer.parseInt(input.readLine()); if(hour==40){ hours=hour*rate; System.out.println("Your normal pay is:"+hours); overtime=hour-40; overtime=overtime*1.5*40; System.out.println("Your overtime pay is:"+overtime); totalPay=hours + overtime; System.out.println("Your total pay is:"+totalPay); break; } case 3: System.out.println("Enter hours:"); hour=Integer.parseInt(input.readLine()); if(hour>40){ hours=hour*rate; System.out.println("Your normal pay is:"+hours); overtime=hour-40; overtime=overtime*1.5*40; System.out.println("Your overtime pay is:"+overtime); totalPay=hours + overtime; System.out.println("Your total pay is:"+totalPay); break; } } } } }
|
|
 | |
Admin Admin

Posts: 67 Join date: 2009-11-24 Age: 20 Location: Philippines
 | Subject: Programming (IF Statement) Sat Nov 28, 2009 2:15 am | |
| public class if_statement{ public static void main(String args[]){ int x=0; System.out.println("Value is:"+x); if(x%2==0) { System.out.println("Value is an even number."); { if(x%2==1) { System.out.println("Value is an odd number."); } } } } } |
|
 | |
Admin Admin

Posts: 67 Join date: 2009-11-24 Age: 20 Location: Philippines
 | Subject: Programming (Students Handy Profile) Sat Nov 28, 2009 2:16 am | |
| import java.io.*; class lx2{ public static void main(String args[])throws IOException {
BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
String firstName,lastName,middle,gender,address; int age,start=1,end; long contact; while(start==1){ System.out.println("Students Handy Profile");
System.out.print(" Enter Name : "); firstName=br.readLine(); System.out.print(" Enter Last name: "); lastName=br.readLine(); System.out.print(" Enter Middle Initial : "); middle=br.readLine(); System.out.print(" Enter Age : "); age=Integer.parseInt(br.readLine()); System.out.print(" Enter Gender : "); gender=br.readLine(); System.out.print(" Enter Address : "); address=br.readLine(); System.out.print(" Enter Contact Number : "); contact=Integer.parseInt(br.readLine()); System.out.println(); System.out.println();
System.out.println("This is your Information"); System.out.println(); System.out.println("Name :"+firstName+" "+middle+" "+lastName); System.out.println("Age :"+age); System.out.println("Gender :"+gender); System.out.println("Address :"+address); System.out.println("Contact No. :"+contact);
end =1; while (end == 1){ try{ System.out.println(); System.out.println();System.out.println(); System.out.print("Retry 1:Yes 2:No : "); start = Integer.parseInt(br.readLine()); end = 2; } catch (Exception e) { System.err.println("Invalid Entry: Read Instruction");
end = 1; }}}}}
|
|
 | |
Admin Admin

Posts: 67 Join date: 2009-11-24 Age: 20 Location: Philippines
 | Subject: Programming (The count is greater than ten) Sat Nov 28, 2009 2:17 am | |
| public class if1 { public static void main(String args[]){ int count=16; if(count>10) { System.out.println("The count is greater than ten"); } } } |
|
 | |
Admin Admin

Posts: 67 Join date: 2009-11-24 Age: 20 Location: Philippines
 | Subject: Programming (The Number is greater than ten) Sat Nov 28, 2009 2:19 am | |
| public class if1 { public static void main(String args[]){ int count=16; if(count>10) { System.out.println("The count is greater than ten"); } } } |
|
 | |
Admin Admin

Posts: 67 Join date: 2009-11-24 Age: 20 Location: Philippines
 | Subject: Programming (Workhours) Sat Nov 28, 2009 2:19 am | |
| import java.io.*; public class l{ public static InputStreamReader reader = new InputStreamReader(System.in); public static BufferedReader input = new BufferedReader(reader); public static void main(String args[]) throws Exception { int rate=35, hour=0, hours=0; double overtimeRate=0, overtime, overHour=0, normalpay, totalPay; int choice,start=1; switch(hour) { case 1:{ System.out.println("Enter hours:"); hour=Integer.parseInt(input.readLine()); if(hour<40){ hours=hour*rate; System.out.println("Your normal pay is:"+hours); overtime=hour-40; overtime=overtime*overtimeRate; overHour=overtime; System.out.println("Your overtime pay is:"+overHour); totalPay=hours + overHour; System.out.println("Your total pay is:"+totalPay); totalPay=Integer.parseInt(input.readLine()); } } break; case 2:{ System.out.println("Enter hours:"); hour=Integer.parseInt(input.readLine()); if(hour==40){ hours=hour*rate; System.out.println("Your normal pay is:"+hours); System.out.println("Your overtime pay is:"+overHour); totalPay=hours + overHour; System.out.println("Your total pay is:"+totalPay); totalPay=Integer.parseInt(input.readLine()); } } break; case 3:{ if(hour>40){ hours=hour*rate; System.out.println("Your normal pay is:"+hours); if(hour>40){ hours=hour*rate; System.out.println("Your normal pay is:"+hours); overtime=hour-40; overtime=overtime*overtimeRate; overHour=rate*40+overtime; System.out.println("Your overtime pay is:"+overHour); totalPay=hours + overHour; System.out.println("Your total pay is:"+totalPay); totalPay=Integer.parseInt(input.readLine()); } } break; } } }}
|
|
 | |
Admin Admin

Posts: 67 Join date: 2009-11-24 Age: 20 Location: Philippines
 | Subject: Programming (The number is not even) Sat Nov 28, 2009 2:20 am | |
| import java.io.*; public class if2 { public static InputStreamReader reader = new InputStreamReader(System.in); public static BufferedReader input = new BufferedReader(reader); public static void main(String args[]) throws Exception { int n; System.out.println("enter the value of n:"); n=Integer.parseInt(input.readLine()); if(n%2==1) { System.out.println("The number is not even."); } } } |
|
 | |
Admin Admin

Posts: 67 Join date: 2009-11-24 Age: 20 Location: Philippines
 | Subject: Programming (Workhours) Sat Nov 28, 2009 2:21 am | |
| import java.io.*; public class LabEx4_No1 { public static InputStreamReader reader = new InputStreamReader(System.in); public static BufferedReader input = new BufferedReader(reader); public static void main(String args[]) throws Exception { int rate=35, hour, hours=0; double overtimeRate=0, overtime=0, overHour=0, totalPay=0; overtimeRate=rate*1.5; System.out.println("The work hour is:"); hour=Integer.parseInt(input.readLine()); hours=hour*rate; if(hour>40){ hours=hour*rate; System.out.println("Your normal pay is:"+hours); overtime=hour-40; overtime=overtime*overtimeRate; System.out.println("Your overtime pay is:"+overtime); totalPay=hours + overtime; System.out.println("Your total pay is:"+totalPay); } else{ System.out.println("Your normal pay is:"+hours); System.out.println("Your overtime pay is:"+overtime); } } } |
|
 | |
Admin Admin

Posts: 67 Join date: 2009-11-24 Age: 20 Location: Philippines
 | Subject: Programming (Nested For) Sat Nov 28, 2009 2:22 am | |
| public class nested_for { public static void main(String[] args) { for(int Row=1;Row<=10;Row++) { for(int Column=1;Column<=10;Column++) { System.out.print(Row*Column+"\t"); } System.out.println(); } } } |
|
 | |
Admin Admin

Posts: 67 Join date: 2009-11-24 Age: 20 Location: Philippines
 | Subject: Programming (ComputeMe) Sat Nov 28, 2009 2:23 am | |
| import java.io.*; public class LabEx3_No1 { public static InputStreamReader reader = new InputStreamReader(System.in); public static BufferedReader input = new BufferedReader(reader); public static void main(String args[]) throws Exception { int n1, n2, Add, Subtract, Multiply, Divide; System.out.println("Enter the n1:"); n1=Integer.parseInt(input.readLine()); System.out.println("Enter the n2:"); n2=Integer.parseInt(input.readLine()); Add=n1+n2; Subtract=n1-n2; Multiply=n1*n2; Divide=n1/n2; System.out.println("Add:"+Add); System.out.println("Subtract:"+Subtract); System.out.println("Multiply:"+Multiply); System.out.println("Divide:"+Divide); } }
|
|
 | |
Admin Admin

Posts: 67 Join date: 2009-11-24 Age: 20 Location: Philippines
 | Subject: Programming (Temperature) Sat Nov 28, 2009 2:24 am | |
| public class LabEx3_No2{ public static void main(String args[]){ float fah = 86; System.out.println(fah + " degrees Fahrenhiet is ..."); //To convert Fahrenheit into Celsius //Begin by subtracting 32 fah = fah / 9; //Multiply that answer by 5 fah = fah * 5; System.out.println(fah + " degrees Celsius \n"); float cel =33; System.out.println(cel + " degrees Celsius is ..."); //To convert Fahrenheit into Celsius //Begin by Subtracting 32 cel = cel * 9; //Divide the answer by 9 cel = cel / 5; //Multiply the answer by 5 cel = cel + 32; System.out.println(cel + " degrees Fahrenheit"); } } |
|
 | |
Admin Admin

Posts: 67 Join date: 2009-11-24 Age: 20 Location: Philippines
 | Subject: Programming (Mod or Remainder) Sat Nov 28, 2009 2:24 am | |
| import java.io.*; public class LabEx3_No3 { public static InputStreamReader reader = new InputStreamReader(System.in); public static BufferedReader input = new BufferedReader(reader); public static void main(String args[]) throws Exception { int n1, n2, quo; double mod; System.out.print("\tEnter the n1:"); n1=Integer.parseInt(input.readLine()); System.out.print("\tEnter the n2:"); n2=Integer.parseInt(input.readLine()); quo=n1/n2; mod=n1%n2; System.out.print("\tThe quotient is:"+quo); System.out.print("\tThe remainder is:"+mod); } } |
|
 | |
| | Programming (Simple Computation) | |
|