0% found this document useful (0 votes)
206 views3 pages

Java 1

The document contains 3 Java programs that take user input and perform calculations: 1) A miles per gallon calculator that takes miles and gallons as input and divides miles by gallons. 2) A discount calculator that takes unit price, quantity, and discount percentage as input to calculate the amount a client should pay after applying the discount. 3) A salary calculator that takes the departure time for 4 days of the week as input to calculate the weekly salary, tax amount, and net salary based on an hourly rate and overtime rules.

Uploaded by

Khalil Raya
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
206 views3 pages

Java 1

The document contains 3 Java programs that take user input and perform calculations: 1) A miles per gallon calculator that takes miles and gallons as input and divides miles by gallons. 2) A discount calculator that takes unit price, quantity, and discount percentage as input to calculate the amount a client should pay after applying the discount. 3) A salary calculator that takes the departure time for 4 days of the week as input to calculate the weekly salary, tax amount, and net salary based on an hourly rate and overtime rules.

Uploaded by

Khalil Raya
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Directed for: Dr.

Jad Abbass By Mohammad Abbass Hellani ID:81130086

I.
import [Link]; public class gln { public static void main(String[]args) { Scanner scan=new Scanner([Link]); int m,g,mg; [Link]("Enter the number of miles: "); m=[Link](); [Link]("Enter the gallons of fuel used: "); g=[Link](); mg= m/g; [Link]("Miles per gallon: "+mg); } }

II.
import [Link]; public class str { public static void main(String [] args) { Scanner scan=new Scanner([Link]); double p,d,t; int q; [Link]("Enter the unit price: "); p=[Link](); [Link]("Enter the quantity: "); q=[Link](); [Link]("Enter the discount %: "); d=[Link](); t=(double) ((p*q)-(d/100)*p*q); [Link]("The client should pay: "+t+" unit price"); } }

III.
import [Link]; public class sale { public static void main(String[]args){ Scanner scan=new Scanner([Link]); int m,t,w,th; double sal=0,totsal=0,tax=0; [Link]("Please enter the time m=[Link](); if(m==4) { sal=sal+7*7; } if(m>4) { sal=sal+(7*7)+(double)(m-4)*8.4; } [Link]("Please enter the time t=[Link](); if(t==4) { sal=sal+7*7; } if(t>4) { sal=sal+7*7+(double)(t-4)*8.4; } [Link]("Please enter the time w=[Link](); if(w==4) { sal=sal+7*7; } if(w>4) { sal=sal+7*7+(double)(w-4)*8.4; } [Link]("Please enter the time th=[Link](); if(th==4) { sal=sal+7*7; } if(th>4) { sal=sal+7*7+(double)(th-4)*8.4; } tax=sal*0.03; you left on Monday:");

you left on Tuesday:");

you left on Wednesday:");

you left on Thursday:");

totsal=sal-tax; [Link]("Your total weekly salary is "+sal+" $"); [Link]("The tax in your salary is "+tax+" $"); [Link]("Your net salary is "+totsal+" $"); } }

You might also like