0% found this document useful (0 votes)
187 views

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)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
187 views

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)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Directed for: Dr.

Jad Abbass By Mohammad Abbass Hellani ID:81130086

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

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

III.
import java.util.Scanner; public class sale { public static void main(String[]args){ Scanner scan=new Scanner(System.in); int m,t,w,th; double sal=0,totsal=0,tax=0; System.out.println("Please enter the time m=scan.nextInt(); if(m==4) { sal=sal+7*7; } if(m>4) { sal=sal+(7*7)+(double)(m-4)*8.4; } System.out.println("Please enter the time t=scan.nextInt(); if(t==4) { sal=sal+7*7; } if(t>4) { sal=sal+7*7+(double)(t-4)*8.4; } System.out.println("Please enter the time w=scan.nextInt(); if(w==4) { sal=sal+7*7; } if(w>4) { sal=sal+7*7+(double)(w-4)*8.4; } System.out.println("Please enter the time th=scan.nextInt(); 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; System.out.println("Your total weekly salary is "+sal+" $"); System.out.println("The tax in your salary is "+tax+" $"); System.out.println("Your net salary is "+totsal+" $"); } }

You might also like