Java 1
Java 1
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:");
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+" $"); } }