lundi 14 septembre 2020

Noob in need of assistance [duplicate]

New to programming here and am taking my first java class. I am still getting used to the jargon and I am trying to do an assignment where we use a scanner to take in a user's age and if the age is over 60 apply a senior discount using if-else statements. I keep getting the following error message: Exercise3.java:28: error: '.class' expected if (int > 60)

I know it is probably a noob mistake (maybe several) but I have tried looking at other people else if statements and can't figure out what I'm doing wrong (it is the only error I get when I try to compile it). (I know the curly bracket locations are not like a lot of code I have seen but my teacher wants it formatted this way with the brackets aligning.)

Below is the code please help:

import java.util.Scanner;

public class Exercise3 
{
     public static int readIntFromInput(String prompt) 
     {
         System.out.print(prompt);
         Scanner sc = new Scanner(System.in);
         int value = sc.nextInt();
         sc.close();
         return value;
     }
     
     public static void main(String [] args);
     {
        
        float temp =10.50f;
        
        
          int ageOfPerson = readIntFromInput("Enter Age: ");
                    
        
        if (int > 60)
            {
            float sd = temp * 0.9f;
            System.out.println  ("Senior Discount Price:" + sd);
            }   
        else
            {
                System.out.println ("Movie Ticket Price:" + temp);
            }
            
        
     }
}
                                           

Aucun commentaire:

Enregistrer un commentaire