在missingDates.Count()
语句中,在参数中我得到一个错误,说“类型不匹配,无法从int转换为boolean”。请提供解决方案。
if
}
答案 0 :(得分:1)
该行
if(sathya1.nextInt(addition){
毫无意义。这就像说“如果12”。其他行也是如此。此外,在许多其他问题中,您错过了结束)
。
答案 1 :(得分:0)
也许你的意思是:
import java.util.Scanner;
public class BasicArithmetic
{
public static void main(String[] args)
{
//create a scanner for keyboard input
Scanner sathya1 = new Scanner(System.in);
//ask user for the operation to be used
System.out.print("Please enter the corresponding number to be used \n(1)for Addition,(2)for Subtraction,(3)for Multiplication,(4)for Division:");
int enteredNumber = sathya1.nextInt();
//get the two numbers to be used
System.out.println("Enter the numbers");
float x = sathya1.nextFloat();
float y = sathya1.nextFloat();
//arithmetic operations of the two numbers
float addition = x+y;
float subtraction = x-y;
float multiplication =x*y;
float division = x/y;
//if..else statement
if(enteredNumber==1)
{
System.out.println("The sum of the two number is "+addition);
}
else if(enteredNumber==2)
{
System.out.println("The subtraction of the two number is "+subtraction);
}
else if(enteredNumber==3)
{
System.out.println("The product of the two number is "+multiplication);
}
else if(enteredNumber==4)
{
System.out.println("The quotient of the two number is "+division);
}
else
{
System.out.println("Please enter the correct corresponding number");
}
}
}