Link to home
Start Free TrialLog in
Avatar of sara_bellum
sara_bellumFlag for United States of America

asked on

Java homework assignment, syntax check

This assignment asks us to verify syntax errors - again, this may seem paranoid, but my grade on the midterm was ridiculously low :(  Syntax errors are noted in my comments at each line; we're supposed to find >= 10 errors.
public class Example2
  static void main(String[] args){  //1. public static void main(String[] args)
     int firstI; secondI;           //2. int firstI, secondI;
     double firstD; secondD;        //3. double firstD, secondD;

     int firstI = 5;               
     int secondI = 10;
     System.out.println("When you add " + firstD + "and + secondI); // 4. + " and " +
     System.out.println("You get: " + addTogether(firstI, secondI); //5. addTogether() undefined
     
     firstD = 3.12;  //6. int firstD;
     secondD = 7.4;  //7. int secondD;
     System.out.println("When you add " + firstD + " and " + secondD);
     System.out.println("You get: " + addTogether(firstD, secondD));  //8. addTogether() undefined
     }
     public static int addTogether(int v1, int v2){
       int totalAdd;  
       totalAdd = v1 + v2;  //9. double totalAdd
       return totalAdded;   //10. totalAdded undefined ... return totalAdd;
     }
     public static double addTogether(double v1, double v2){
      double totalAdd;
       totalAdd = v1 + v2;
      return totalAdded; //11. totalAdded undefined ... return totalAdd;
      }
      }
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mujtaba_Alam_Khan
Mujtaba_Alam_Khan

Thank You ;-)
Avatar of sara_bellum

ASKER

These were wonderful answers and yes, Mujtaba, they did help me understand Java a little better - I was so stressed at the time that I didn't bother posting a comment, but should have ;-)