import java.util.Scanner;
public class AgeGuess {
public static void main(String[] args) {
Scanner scan= new Scanner(System.in); // reading from keyboard new scanner object
System.out.print ("Enter the name: ");
String name = scan.nextLine(); // Adding name
System.out.print ("Enter the age: ");
int ageGuess = scan.nextInt(); // Adding Age
System.out.println ("Name is "+ name); // Display name
System.out.println ("Age is "+ ageGuess); //Display age Guess
//***********************************************************************************************
// Lab 2 Exercise 1: Modify the AgeGuess program to do the following:
// Declare a new int variable - initialize age to a random integer between 0 and 100 (inclusive)
// Asks the user for a guess, save the guess in the ageGuess variable
// Display the correct answer
dimanche 8 novembre 2020
Utilizing Java, I need to modify the AgeGuess program I made before to do the following as written below in Lab 2 Exercise 1
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire