Sie sind auf Seite 1von 7

class multiCalculator{ public static void main(String args[]){ System.out.println("What do you want to use ?"); System.out.

println("1)Average Calculator, 2)Currency Converter,"); System.out.println("3)Normal Calculator ?, 4)Volume of 3D Shapes Calculator ?"); System.out.println("or 5)Area of 3D Shapes Calculator?"); System.out.println(); System.out.println(); System.out.println(); int choice = Keyboard.readInt(); if(choice < 2){ System.out.println("This is an average calculator"); System.out.println("How many numbers are you going to use?"); System.out.println("Minimum is 2 and Maximum is 5"); System.out.println("Number > 5, 5 is chosen. Number < 2, 2 is chosen"); double x1 = Keyboard.readDouble(); if(x1 < 3){ System.out.println("Please insert two numbers."); System.out.println("First number: "); double n1 = Keyboard.readDouble(); System.out.println("Second number: "); double n2 = Keyboard.readDouble(); double n3 = (n1+n2)/2; System.out.println("The average of: "+n1+" and "+n2+" is "+n3); System.out.println("If you want to use the average calculator again, typ e '1', or else, just close"); int n5 = Keyboard.readInt(); if(n5 > 0)if(n5 < 2){ System.out.println("Please insert two numbers."); System.out.println("First number: "); double b1 = Keyboard.readDouble(); System.out.println("Second number: "); double b2 = Keyboard.readDouble(); double b3 = (b1+b2)/2; System.out.println("The average of: "+n1+" and "+n2+" is "+b3); } } else if(x1 < 4){ System.out.println("Please insert three numbers."); System.out.println("First number: "); double n1 = Keyboard.readDouble(); System.out.println("Second number: "); double n2 = Keyboard.readDouble(); System.out.println("Third number: "); double n3 = Keyboard.readDouble(); double n4 = (n1+n2+n3)/3; System.out.println("The average of: "+n1+", "+n2); System.out.println(" and "+n3+" is "+n4);

System.out.println("If you want to use the average calculator again, typ e '1', or else, just close"); int n6 = Keyboard.readInt(); if(n6 > 0)if(n6 < 2){ System.out.println("Please insert three numbers."); System.out.println("First number: "); double b1 = Keyboard.readDouble(); System.out.println("Second number: "); double b2 = Keyboard.readDouble(); System.out.println("Third number: "); double b3 = Keyboard.readDouble(); double b4 = (b1+b2+b3)/3; System.out.println("The average of: "+b1+", "+b2); System.out.println(" and "+b3+" is "+b4); } } else if(x1 < 5){ System.out.println("Please insert four numbers."); System.out.println("First number: "); double n1 = Keyboard.readDouble(); System.out.println("Second number: "); double n2 = Keyboard.readDouble(); System.out.println("Second number: "); double n3 = Keyboard.readDouble(); System.out.println("Second number: "); double n4 = Keyboard.readDouble(); double n5 = (n1+n2+n3+n4)/4; System.out.println("The average of: "+n1+", "+n2); System.out.println(", "+n3+" and "+n4+" is "+n5); System.out.println("If you want to use the average calculator again, typ e '1', or else, just close"); int n7 = Keyboard.readInt(); if(n7 > 0)if(n7 < 2){ System.out.println("Please insert four numbers."); System.out.println("First number: "); double b1 = Keyboard.readInt(); System.out.println("Second number: "); double b2 = Keyboard.readInt(); System.out.println("Third number: "); double b3 = Keyboard.readInt(); System.out.println("Fourth number: "); double b4 = Keyboard.readInt(); double b5 = (b1+b2+b3+b4)/4; System.out.println("The average of: "+b1+", "+b2); System.out.println(", "+b3+" and "+b4+" is "+b5); } } else if(x1 > 4){

System.out.println("Please insert five numbers."); System.out.println("First number: "); double n1 = Keyboard.readInt(); System.out.println("Second number: "); double n2 = Keyboard.readInt(); System.out.println("Third number: "); double n3 = Keyboard.readInt(); System.out.println("Fourth number: "); double n4 = Keyboard.readInt(); System.out.println("Fifth number: "); double n5 = Keyboard.readInt(); double n6 = (n1+n2+n3+n4+n5)/5; System.out.println("The average of: "+n1+", "+n2+", "+n3); System.out.println(", "+n4+" and "+n5+" is "+n6); System.out.println("If you want to use the average calculator again, typ e '1', or else, just close"); int n8 = Keyboard.readInt(); if(n8 > 0)if(n8 < 2){ System.out.println("Please insert two numbers."); System.out.println("First number: "); double b1 = Keyboard.readDouble(); System.out.println("Second number: "); double b2 = Keyboard.readDouble(); System.out.println("Third number: "); double b3 = Keyboard.readDouble(); System.out.println("Fourth number: "); double b4 = Keyboard.readDouble(); System.out.println("Fifth number: "); double b5 = Keyboard.readDouble(); double b6 = (b1+b2+b3+b4+b5)/5; System.out.println("The average of: "+b1+", "+b2+", "+b3); System.out.println(", "+b4+" and "+b5+" is "+b6); } } } else if(choice < 3){ System.out.println("Insert a Euro amount"); double n1 = Keyboard.readDouble(); System.out.println(); System.out.println(); System.out.print(n1); System.out.println(" Euro is equal to...."); System.out.println(); //Dollars double $ = n1*1.31882; System.out.print($); System.out.println(" US Dollars"); //GBP double gbp = n1*0.816822; System.out.print(gbp);

System.out.println(" British Pounds (or sterling)"); //AUD double aud = n1*1.27676; System.out.print(aud); System.out.println(" Australian Dollars"); //MLT double mlt = n1*0.43; System.out.print(mlt); System.out.println(" Maltese Liri"); //INR double inr = n1*69.2403; System.out.print(inr); System.out.println(" Indian Rupee"); //AED double aed = n1*4.85235; System.out.print(aed); System.out.println(" Emirati Dirham"); } else if(choice < 4){ System.out.println("What do you want to do ? 1)Addition ? 2)Subtraction ? 3) Division ?"); System.out.println("4)Multiplication ? 5)Square a number ? or 6)Calculate an average between 2 numbers"); double n1 = Keyboard.readDouble(); if(n1 < 2){ System.out.println("Choose two numbers to add together"); System.out.print("First number: "); double n2 = Keyboard.readDouble(); System.out.print("plus second number: "); double n3 = Keyboard.readDouble(); double n4 = n2+n3; System.out.print("Answer is: "); System.out.print(n4); } else if(n1 < 3){ System.out.println("Choose two numbers to subtract by eachother"); System.out.print("First number: "); double n2 = Keyboard.readDouble(); System.out.print("minus second number: "); double n3 = Keyboard.readDouble(); double n4 = n2-n3; System.out.print("Answer is: "); System.out.print(n4); } else if(n1 < 4){ System.out.println("Choose two numbers to divide by eachother"); System.out.print("First number: "); double n2 = Keyboard.readDouble(); System.out.print("division by second number: "); double n3 = Keyboard.readDouble(); double n4 = n2/n3; System.out.print("Answer is: "); System.out.print(n4); } else if(n1 < 5){ System.out.println("Choose two numbers to multiply together");

System.out.print("First number: "); double n2 = Keyboard.readDouble(); System.out.print("multiplied by second number: "); double n3 = Keyboard.readDouble(); double n4 = n2*n3; System.out.print("Answer is: "); System.out.print(n4); } else if(n1 < 6){ System.out.println("Choose a number to square"); double n2 = Keyboard.readDouble(); double n3 = n2 * n2; System.out.print("The Answer is: "); System.out.print(n3); } else if(n1 < 7){ System.out.println("Choose two numbers to find their average"); System.out.print("First number: "); double n2 = Keyboard.readDouble(); System.out.print("and second number: "); double n3 = Keyboard.readDouble(); double n4 = (n2+n3)/2; System.out.print("Answer is: "); System.out.print(n4); } } else if(choice < 5){ //(pi = 3.14159265)(2pi = 6.28318530)(4pi = 12.56637051) System.out.println("For what shape do you want to calculate the volume?" ); System.out.println("1)Sphere, 2)Cube, 3)Regular Prism,"); System.out.println("4)Cylinder, 5)Square Pyramid or 6)Cone ?"); double n1 = Keyboard.readDouble(); if(n1 < 2){ System.out.println("Please enter the sphere's radius"); double r1 = Keyboard.readDouble(); //radius double n2 = r1*r1*r1; //radius cubed double pi = 3.14159265; //pi double n3 = 4/3; //4 divided by 3 double vol = n3*pi*n2; //total volume System.out.println("The volume is: "+vol+" centimetres cubed"); } else if(n1 < 3){ System.out.println("Please enter a side length from the cube"); double s1 = Keyboard.readDouble(); //cube's side double vol = s1*s1*s1; //cube's side cubed = total volume System.out.println("The volume is: "+vol+" centimetres cubed"); } else if(n1 < 4){ System.out.println("Please enter the prism's length,"); System.out.println("width and height in any order"); double n3 = Keyboard.readDouble(); //length, width or height double n4 = Keyboard.readDouble(); //length, width or height double n5 = Keyboard.readDouble(); //length, width or height double vol = n3*n4*n5; //total volume System.out.println("The volume is: "+vol+" centimetres cubed"); } else if(n1 < 5){ System.out.println("Please, first enter the cylinder's radius"); System.out.println("and then enter it's length in that order");

double n6 = Keyboard.readDouble(); //radius double n7 = Keyboard.readDouble(); //length double r1 = n6*n6; //radius squared double pi = 3.14159265; //pi double vol = pi*r1*n7; //total volume System.out.println("The volume is: "+vol+" centimetres cubed"); } else if(n1 < 6){ System.out.println("Please enter the pyramid's base length,"); System.out.println("base width and height in any order"); double n8 = Keyboard.readDouble(); //base length, base width or heig ht double n9 = Keyboard.readDouble(); //base length, base width or heig ht double n10 = Keyboard.readDouble(); //base length, base width or hei ght double n11 = (n8*n9*n10)/3; //total volume System.out.println("The volume is: "+n11+" centimetres cubed"); } else if(n1 > 5){ System.out.println("Please enter the cone's radius"); System.out.println("and it's height in that order"); double n12 = Keyboard.readDouble(); //radius double n13 = Keyboard.readDouble(); //height double pi = 3.14159265; //pi double n14 = n12*n12; //radius squared double vol = (pi*n14*n13)/3; //total volume } } else if(choice > 4){ //(pi = 3.14159265)(2pi = 6.28318530)(4pi = 12.56637051) System.out.println("For what shape do you want to calculate the area?"); System.out.println("1)Sphere, 2)Cube, 3)Cylinder,"); System.out.println("4)Square Pyramid or 5)Cone ?"); double n1 = Keyboard.readDouble(); if(n1 < 2){ System.out.println("Please enter the sphere's radius"); double n2 = Keyboard.readDouble(); //radius double n3 = n2*n2; //radius squared double pi4 = 12.56637051; //pi * 4 double area = pi4*n3; //total area System.out.println("The surface area is: "+area+" centimetres square d"); } else if(n1 < 3){ System.out.println("Please enter one of the cube's side's length"); double n4 = Keyboard.readDouble(); //side length double area = n4*n4; //total area System.out.println("The area of one of the cube's faces is: "+area+" centimetres squared"); } else if(n1 < 4){ System.out.println("Please enter the cylinder's radius"); System.out.println("and length in that order"); double n5 = Keyboard.readDouble(); //radius double n6 = Keyboard.readDouble(); //length double pi2 = 6.28318530; //pi * 2 double area = n5*n6*pi2; //total area System.out.println("The surface area is: "+area+" centimetres square d");

} else if(n1 < 5){ System.out.println("Please enter the pyramid's base length,"); System.out.println("base width and it's slant height in that order") ; System.out.println("(It's not a problem if you change the length wit h the width"); double l1 = Keyboard.readDouble(); //length or width double w1 = Keyboard.readDouble(); //length or width double sh = Keyboard.readDouble(); //slant height double bArea = l1*w1; //base area double pArea = l1+w1; //perimeter of base *2 /2 double tArea = bArea+(pArea*sh); //total area System.out.println("The surface area is: "+tArea+" centimetres squar ed"); } else if(n1 > 4){ System.out.println("What do you want to find ? 1)The curved surface" ); System.out.println("area ? or 2)The total surface area ?"); double choice2 = Keyboard.readDouble(); if(choice2 < 2){ System.out.println("Please enter the radius and height"); System.out.println("of the cone in any order"); double n9 = Keyboard.readDouble(); //radius or height double n10 = Keyboard.readDouble(); //radius or height double pi = 3.14159265; //pi double area = n9*n10*pi; //total area System.out.println("The curved surface area is: "+area+" centime tres squared"); } else if(choice2 > 1){ System.out.println("Please enter the radius and height"); System.out.println("of the cone in that order"); double r1 = Keyboard.readDouble(); //radius double h1 = Keyboard.readDouble(); //height double pi = 3.14159265; //pi double area1 = r1*h1*pi; //curved area double r2 = r1*r1; //radius squared double area2 = pi*r2; //base double area3 = area1+area2; //total area System.out.println("The total surface area is: "+area3+" centime tres squared"); } } } } }

Das könnte Ihnen auch gefallen