小编Ros*_*ung的帖子

麻烦与&&运算符

在下面的代码&&中,if else语句中给出了语法错误,我不确定如何解决它.有人能提供解决方案吗?

//Importing scanner
import java.util.Scanner;

public class Credithistory {

    public static void main(String[] args) {            
        //Stating scanner gets its input from console
        Scanner scanner= new Scanner (System.in);           
        //declaring int and boolean         
        int age;
        boolean goodCreditHistory;          
        System.out.println("Please enter your age... ");
        age= scanner.nextInt();         
        System.out.println("Do you have a good credit history (true or flase)?");
        goodCreditHistory= scanner.nextBoolean();           
        if  (age>=18) && ( goodCreditHistory== true){ // <-------------- Error   
            System.out.println("You have got a credit card!");              
        } else 
            System.out.println ("Sorry you are not eligible …
Run Code Online (Sandbox Code Playgroud)

java if-statement

3
推荐指数
2
解决办法
161
查看次数

标签 统计

if-statement ×1

java ×1