import java.util.*;
public class bad {
public static void main(String []args)
{
Scanner input;
input = new Scanner(System.in);
System.out.println("Enter First Num ");
int a =input.nextInt();
input.nextLine();
System.out.println("Enter Secound Num ");
int b =input.nextInt();
input.nextLine();
System.out.println("For Addition press a" );
System.out.println("For Subtraction press s" );
System.out.println("For Multiplication press m" );
System.out.println("For Divide press d" );
System.out.println("For Square and Cube press c" );
//the Square and cube depend apone you wither you have to Square or cube.
System.out.println("For Root press r");
String store =input.nextLine();
if (store .equals("a"))
{
System.out.print("Answear is: ");
System.out.print(a+b);
}
else if(store .equals("m"))
{
System.out.print("Answear is: ");
System.out.print(a*b);
}
else if(store .equals("d"))
{
System.out.print("Answear is: ");
System.out.print(a/b);
}
else if(store .equals("s"))
{
System.out.print("Answear is: ");
System.out.print(a-b);
}
else if(store .equals("c"))
{
System.out.println("Answear for the power is : ");
System.out.print(Math.pow(a,b));
}
else if (store.equals("r"))
{
System.out.println("Answear is : ");
System.out.println(Math.sqrt(a));
}
}
}
我的程序不停地反复运行意味着该程序要求用户再次输入数字吗?有很多搜索但却没有得到基本的想法。也许while循环可以工作,但是两次使用它却没有得到它。
怎么样使用这样的东西,
boolean run = true;
while(run) {
//when the condition to terminate the program is met
//set run to false
run = false;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句