Académique Documents
Professionnel Documents
Culture Documents
import java.util.Scanner;
do
{
System.out.print("\nEnter your choice for calculation \n");
System.out.print("1. Addition\n");
System.out.print("2. Subtraction\n");
System.out.print("3. Multiplication\n");
System.out.print("4. Division\n");
System.out.print("5. Exit\n\n");
System.out.print("Enter Your Choice : ");
ch = scan.next().charAt(0);
switch(ch)
{
case '1' : System.out.print("Enter Numbers for addition : ");
a = scan.nextFloat();
b = scan.nextFloat();
r = a + b;
System.out.print("Result of addition = " + r);
break;
case '2' : System.out.print("Enter Number for subtraction : ");
a = scan.nextFloat();
b = scan.nextFloat();
r = a - b;
System.out.print("Result of subtraction = " + r);
break;
case '3' : System.out.print("Enter Number for multiplication: ");
a = scan.nextFloat();
b = scan.nextFloat();
r = a * b;
System.out.print("Result Multiplication = " + r);
break;
case '4' : System.out.print("Enter Number for division : ");
a = scan.nextFloat();
b = scan.nextFloat();
r = a / b;
System.out.print("Result of division = " + r);
break;
case '5' : System.exit(0);
break;
default : System.out.print("WRONG CHOICE");
break;
}
}while(ch != 5);
}
}
----------------------------------------------------------------
package floyed;
import java.util.Scanner;
public class Floyed {
System.out.println();
}
}
}
---------------------------------------------------------------
package pyramid;
import java.util.Scanner;
}
--------------------------------------------------
package quadequ
import java.util.*;
class Quadequ
{
public static void main(String args[])
{
double x, y, z;
double r1, r2;
double d, sqr;
System.out.println("\nEnter The Values");
Scanner sc = new Scanner(System.in);
System.out.println(" x: ");
x = sc.nextFloat();
System.out.println(" y: ");
y = sc.nextFloat();
System.out.println(" z: ");
z = sc.nextFloat();
d = y*y - 4*x*z;
sqr = Math.sqrt(d);
if(d<0)
{
System.out.println("\n Roots Are Imaginary \n");
}
else
{
r1 = (-y + sqr) / (2*x);
r2 = (-y - sqr) / (2*x);
System.out.println("\n Value of Root 1 = " + r1 + "\n");
System.out.println("\n Value of Root 2 = " + r2 + "\n");
}
}
}