write a algorithm in pseudocode for the procedure: input a person's age and salary. If the age is over 32, then add $1000 to the salary but otherwise subtract $500 from the salary. Finally, output the age and new salary: this is the question:
here is the answer well the code that I use, am wondering if i did it correctly:

Scanner scan = new Scanner (System.in);
       int age, salary, sum, difference;

       System.out.println("Please enter the person age");
       age = scan.nextInt();

       System.out.println("Please enter the person salary");
       salary = scan.nextInt();

       if(age>32)
       {
          sum = salary + 1000;

          System.out.println("the age is " + age);
         }

       else if(age<32)
       {
          difference = salary - 500;

          System.out.println("the new salary is");

an correctness in your code

//You are enter here if age>32
if(age>32){
    //there are equal to salary = salary + 1000 (salary += 1000)
    //or ... your new salary is the olderSalary + 1000
    salary += 1000; 
    System.out.println("your salary is: " + salary);
}else{//else are used if your first condition is false, then you enter here if age <= 32
    //there are equal to salary = salary - 500 (salary -= 500)
    //or ... your new salary is the olderSalary - 500
          salary -= 500;
    System.out.println("your salary is: " + salary);
}

is all. try!

Edited 2 Years Ago by zolymo

if you want the age and new salary output in the end then take all your outputs outside the if and else statement.

also, if you don't have anything else to check, just use else not else if

Edited 2 Years Ago by redtribal23: update

This article has been dead for over six months. Start a new discussion instead.