lundi 17 août 2020

Conditional Expressions: Error message saying incomplete types

I can't seem to figure this out. I feel like it so easy that I am missing it. I keep getting an error message saying incomplete types and pointing at the ? What am I doing wrong?

Using a conditional expression, write a statement that increments numUsers if updateDirection is 1, otherwise decrements numUsers. Ex: if numUsers is 8 and updateDirection is 1, numUsers becomes 9; if updateDirection is 0, numUsers becomes 7.

Hint: Start with "numUsers = ...".

import java.util.Scanner;

public class UpdateNumberOfUsers {
   public static void main (String [] args) {
      Scanner scnr = new Scanner(System.in);
      int numUsers;
      int updateDirection;

      numUsers = scnr.nextInt();
      updateDirection = scnr.nextInt();
      String condStr; 
     
      condStr = (numUsers < 8) ? +1 : -1;

      System.out.println("New value is: " + numUsers);
   }
}

Aucun commentaire:

Enregistrer un commentaire