More Related Content
Similar to import java.uti-WPS Office.docx
Similar to import java.uti-WPS Office.docx (20)
import java.uti-WPS Office.docx
- 1. importjava.util.*;
classApp {
publicstaticvoidmain(String[] args) {
Scannerkeyboard= new Scanner(System.in);
System.out.print("Enternumber:");
intnumber= keyboard.nextInt();
if (number%9 == 0 && number% 2 == 0) {
System.out.println(number+" isevenlydivisibleby9");
} else {
System.out.println(number+" isNOT evenlydivisible by9");
}
keyboard.close();
}
}
- 3. double h,b;
System.out.print("Enterbase of the triangle:");
b=in.nextDouble();
System.out.print("Enterheightof the triangle:");
h=in.nextDouble();
double area=0.5*b*h;
System.out.println("nAreaof the triangle ="+area);
}
publicstaticvoidmain(String[] args) {
intc;
System.out.print("n1.Rectanglen2.Circlen3.TrianglenSelectafigure:");
c=in.nextInt();
if (c==1){
RectangleArea();
}
else if (c==2){
CircleArea();
}
else if (c==3){
TriangleArea();
}
else{
- 4. System.out.println("Invalidinput");
}
}
}importjava.util.Scanner;
class Menu
{
publicstaticvoidmain(String[] args) {
ScannermyScanner=newScanner(System.in);
double choice,total,price ,number;
System.out.println("****jamal anddaughterspub****");
System.out.print("n1.Tusker....ksh.100n2.Pilsner....Ksh.120n3.SmirnoffIce....Ksh.120n4.WhiteCap....
Ksh.90");
System.out.println("nEnteryourchoice:");
choice =myScanner.nextDouble();
// calc the cost multipliedbyquantity
// tusker
if (choice==1){
System.out.println("nHowmanybottlesof Tuskerdoyouwant?");
number=myScanner.nextDouble();
- 5. total=number*100;
System.out.println("nBottlesof Tuskerwill costyou"+total );
}
//pilsner
else if (choice==2){
System.out.println("nHowmanybottlesof Pilsnerdoyouwant ?");
number=myScanner.nextDouble();
total=number*120;
System.out.println("nBottlesof Pilsnerwill costyou"+total );
}
//smirnoffIce
else if (choice==3){
System.out.println("nHowmanybottlesdoyouwant?");
number=myScanner.nextDouble();
total=number*140;
System.out.println("nBottlesof SmirnoffIce will costyou"+total );
}
//whitecap
else if (choice==4){
System.out.println("nHowmanybottleswhite capdoyouwant ?");
number=myScanner.nextDouble();
- 6. total=number*90;
System.out.println("nBottlesof WhiteCap will costyou" +total );
}
//null
else{
System.out.println("ENTERA VALIDCHOICE");
}
}
}
classCalculateDistance
{
publicstaticvoidmain(Stringargs[])
{
double speed,distance,time;
Scannersc=newScanner(System.in);
System.out.println("enterspeedinkmph");
speed=sc.nextDouble();