Assignment4.java - Assignment Arizona State U CSE205#4 Name...

This preview shows page 1 - 2 out of 2 pages.

// Assignment : Arizona State U. CSE205 #4 // Name: Eisa Taherkalateh // StudentID: 1212943431 // Lecture: MWF 9:40-10:30 // Description: Assignment 4 class displays a menu of choices to a user // and performs the chosen task. It will keep asking a user to // enter the next choice until the choice of 'Q' (Quit) is entered. // Time spent: 40 minutes import java.util.*; public class Assignment4 { public static void main (String[] args) { // local variables, can be accessed anywhere from the main method char input1 = 'Z'; String inputInfo; String brandName, modelName; double price, cpuSpeed; int ramSize; String line = new String(); // instantiate a Laptop object Laptop laptop1 = new Laptop(); printMenu(); //Create a Scanner object to read user input Scanner scan = new Scanner(System.in); do // will ask for user input { System.out.print("What action would you like to perform?\n"); line = scan.nextLine(); if (line.length() == 1) { input1 = line.charAt(0); input1 = Character.toUpperCase(input1); // matches one of the case statement switch (input1) { case 'A': //Add the laptop System.out.print("Please enter the laptop information:\n"); System.out.print("What is the laptop\'s brand?\n");

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture