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();

          sum = salary + 1000;

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

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

          System.out.println("the new salary is");
3 Years
Discussion Span
Last Post by divinity02

an correctness in your code

//You are enter here 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 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 by redtribal23: update

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.