some Java programs part 3
//11//Question: Write a program to compute and display a person’s weekly salary as determined by the following conditions: If the hours worked are less than or equal to 40, the person receives Tk200.00 per hour, else the person receives Tk8000.00 plus Tk300.00 for each hour worked over 40 hours.
/* Time: 11.35am
* Author: Anik Das
* Question: Write a program to compute and display a person’s weekly salary as determined by
* the following conditions: If the hours worked are less than or equal to 40, the person receives
* Tk200.00 per hour, else the person receives Tk8000.00 plus Tk300.00
* for each hour worked over 40 hours.*/
import java.util.Scanner;
public class Faraz11{
public static void main (String args []){
int workHr, sal=0;
Scanner input = new Scanner ( System.in );
System.out.println("Enter Your Work Hour(s)");
workHr = input.nextInt();
if ( workHr<=40 ){ sal = workHr*200; } if ( workHr>40 ){
sal = 8000 + 300*( workHr - 40 );
}
System.out.println("Yor Sallery Is : Taka "+sal);
}
}
//12// question: Write a program, given an “amount” of money. It shows it split into 500, 100, 50, 20, 10, 5, 2 and 1 taka bills or coins. The output would be: Say for 1234 it says:
- 500 Taka: 2 note(s)
- 100 Taka: 2 note(s)
- 50 Taka: 0 note(s)
- 20 Taka: 1 note(s)
- 10 Taka: 1 note(s)
- 5 Taka: 0 note(s)
- 2 Taka: 2 note(s)
- 1 Taka: 0 note(s)
/* Time: 12:01pm
* Author: Anik Das
* question: Write a program, given an “amount” of money.
* It shows it split into 500, 100, 50, 20, 10, 5, 2 and 1 taka bills or coins. The output would be:
Say for 1234 it says:
500 Taka: 2 note(s)
100 Taka: 2 note(s)
50 Taka: 0 note(s)
20 Taka: 1 note(s)
10 Taka: 1 note(s)
5 Taka: 0 note(s)
2 Taka: 2 note(s)
1 Taka: 0 note(s)*/
import java.util.Scanner;
public class Faraz12 { //original MoneySplit
public static void main (String[]args) {
int oneTaka=0, twoTaka=0, fiveTaka=0, tenTaka=0;
int twentyTaka=0, fiftyTaka=0, hundredTaka=0, fiveHundredTaka=0;
int amount;
Scanner input = new Scanner ( System.in );
System.out.println("Enter Your Amount of Money");
amount = input.nextInt();
int K=amount%500;
fiveHundredTaka = (amount - K)/500;
int A=K%100;
hundredTaka=(K-A)/100;
int B=A%50;
fiftyTaka=(A-B)/50;
int C=B%20;
twentyTaka=(B-C)/20;
int D=C%10;
tenTaka=(C-D)/10;
int E=D%5;
fiveTaka=(D-E)/5;
int F=E%2;
twoTaka=(E-F)/2;
int G=F%1;
oneTaka=(F-G)/1;
System.out.println("500 Taka: "+fiveHundredTaka+" note(s)n100 Taka: "+hundredTaka+" note(s)n50 Taka: "+fiftyTaka+" note(s)n20 Taka: "+twentyTaka+" note(s)n10 Taka: "+tenTaka+" note(s)n5 Taka: "+fiveTaka+" note(s)n2 Taka: "+twoTaka+" note(s)n1 Taka: "+oneTaka+" note(s)");
}
}
//13// Suppose the following expressions are used to calculate the values of L for different values of S:
L = 12000/(4+(s*s/14900))
/*Time: 4:39pm
* Author: Anik Das*/
import java.util.Scanner;
public class Faraz14{
public static void main ( String [] args){
double s=0, l=0;
Scanner input = new Scanner ( System.in );
System.out.println("Enter The Value Of S :");
s = input.nextInt();
l=12000/(4+(s*s/14900));
System.out.println("The Value Of L is : "+l);
}
}
//15//Write a program that reads the values for the three sides x, y, and z of a triangle, and then calculates its area. The area is calculated as follows:
area = √(s*(s-x)*(s-y)*(s-z))
where s is (x+y+z)/2
/*Time: 4:46pm
* Author: Anik Das*/
import java.util.Scanner;
public class Faraz15{
public static void main ( String [] args ){
double area=0, c=1, s, x=0, y=0, z=0;
Scanner input = new Scanner ( System.in );
System.out.println("Enter The Value of The 1st Side");
x=input.nextDouble();
System.out.println("Enter The Value of The 2nd Side");
y=input.nextDouble();
System.out.println("Enter The Value of The 3rd Side");
z=input.nextDouble();
s=(x+y+z)/2;
area = Math.sqrt(s*(s-x)*(s-y)*(s-z));
System.out.println("Area Of the Triangle Is : "+area);
}
}
April 16, 2011 @ 6:49 am
Awesome job dost!! 🙂
April 16, 2011 @ 7:10 am
Thanx dost… 🙂