Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Java code error: One curly brace is missing

    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 453
    Answer it

    Following is my code- 

    import java.util.Scanner;
    
    public class Sample {
    
    public static void main (String [] args){
    
    Scanner myObj = new Scanner (System.in);
    
    System.out.println(Hello.Do you want to check your cuteness percentage?");
    
    String answer = myObj.nextLine();
    
    if (answer.equals ("Yes") ){
    
    System.out.println("Welcome. Your name:");
    
    } if else (answer.equals ("No") ) {
    
    System.out.println("ok");
    
    }else {
    
    System.out.println("Please enter yes or no");
    
    String subAnswer = myObj.nextLine ();
    
    System.out.println("Your age");
    
    int lastAnswer = myObj.nextInt ();
    
    if (subAnswer.equals ("Shruti") && lastAnswer == 18 ){
    
    System.out.println(subAnswer +"-you're cuteness is 29%");
    
    }else if (subAnswer.equals ("Rudra") && lastAnswer==12) {
    
    System.out.println(subAnswer +"-you're 30% cute");
    
    } else if (subAnswer.equals ("Swati")&& lastAnswer==1) {
    
    System.out.println(subAnswer+"-you're 2% cute");
    
    }else{
    
    System.out.println("No cuteness ");
    
    }
    
    }
    
    }

    This is my program and l want that when it asks the first question, and the user answers yes then it will say welcome and continue asking name and age. When user answers no, it says ok and no ask name and age and if user says something else then it will say please answer yes or no. But when l compile and try to run it, it says error= that one curly brace is missing ("reached the end of the file while phrasing")^{. 

    Please help me...

 0 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: