package com.itany.sj;
import java.util.Scanner;
public class Test23
{
public static void main(String[] args)
{
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
int num1, num2;
String ope;
num1 = input.nextInt();
ope = input.next();
while (ope.equals("+") || ope.equals("-") || ope.equals("*") || ope.equals("/"))
{
num2 = input.nextInt();
if (ope.equals("+"))
{
num1 = num1 + num2;
ope = input.next();
}
if (ope.equals("-"))
{
num1 = num1 - num2;
ope = input.next();
}
if (ope.equals("*"))
{
num1 = num1 * num2;
ope = input.next();
}
if (ope.equals("/"))
{
num1 = num1 / num2;
ope = input.next();
}
}
if (ope.equals("="))
{
System.out.println(num1);
}
input.close();
}
}
我算到第4数个就停下了,算到除法也就停下了,我要可以随便运算几个式子,帮忙解决这个就行了。不要太难的啊,我只会while,if,switch,
简化一下,这样
字符数组:a,b,A,=,+,1,a,b,a,*,B,C统计出里面出现的字符及它们各自的个数,用Java语言编写!
初学者,只学了,for,if,which,switch,会用Scanner不要用我不知道的循环语句谢谢啊