Ok so this is my code so far: I have a issue where near the end in the getSum() method I need a way for the all the methods that i have that ask for the user input need to go into the respective arrays that i made in the getSum method then the prices i assigned in my Constructor to be linked to each selection the user made for that particular component for their computer and then display the "reciept" in the DisplayResults method...racking my brain trying to figure that out...
Thanks guys
public class Computer
{
//memory locations
//initialized to zero before setting prices
private double processorSpeed = 0;
private double memory = 0;
private double diskSize = 0;
private double screenSize = 0;
private String inputResponse;
//default constructor
public Computer()
{
}
//assigns prices
public Computer(double processorSpeed , double memory , double diskSize , double screenSize)
{
//prices for computer parts
//goes up by each next higher model
//i.e Intel i3 $40 so next higher will be $80 , same for Ram
processorSpeed = 40;
memory = 10;
diskSize = 20;
screenSize = 10;
} // end of Computer constructor for prices
//userPrompt
static Scanner userInput = new Scanner(System.in);
public static void DisplayInstructions()
{
/// User Prompt
System.out.println("Hi Welcome to Sam and Johnny's PC Shop! Please type enter to continue..." );
//initialize Scanner variable and set it too null
//take user input to proceed to next Screen
String pressAnyKey;
pressAnyKey = userInput.next();
}
public static void notebookOrDesktop(){
System.out.print("What would you like to purchase today? ");
System.out.println("\n\n1.PC\n2.Laptop");
System.out.println("\nPlease type number for selection");
String selectOptionSystem;
do {
selectOptionSystem= userInput.next();
if (selectOptionSystem.equalsIgnoreCase("1"))
{
}else{
screenSize();
}
} while (false);
}
public static void processor(){
System.out.print("What processor would you like to have? ");
System.out.println("\n\n1. Intel i7 \n2. Intel i5 \n3. Intel i3");
System.out.println("\nPlease type number for selection");
String selectOption;
selectOption = userInput.next();
}
public static void ram(){
System.out.print("How much RAM would you like to have? ");
System.out.println("\n\n1. 2gb \n2. 4gb \n3. 8gb");
System.out.println("\nPlease type number for selection");
String selectOption;
selectOption = userInput.next();
}
public static void diskSize(){
System.out.print("How much disk space do you need? ");
System.out.println("\n\n1. 200gb \n2. 400gb \n3. 1 tb");
System.out.println("\nPlease type number for selection");
String selectOption;
selectOption = userInput.next();
}
public static void screenSize(){
System.out.print("\nPlease Choose Your Screen Size ");
System.out.println("\n\n1.13in \n2. 15in \n3. 17in");
System.out.println("\nPlease type number for selection");
String selectOption;
selectOption = userInput.next();
}
public static void DriveOption()
{
System.out.println("Would you like to add a CD Drive or DVD Drive? Enter Y or N ");
String selectOption;
selectOption = userInput.next();
do {
selectOption= userInput.next();
if (selectOption.equalsIgnoreCase("N"))
{
//have it total and displayResults();
DisplayResults();
}else{
DriveOption();
}
} while (false);
}
public static void DisplayResults()
{
System.out.println("Your order and total:");
} // end of DisplayResults
public static void getSum()
{
//need to have what ever component user selected and store that part with the price into array and loop and total all the parts and
//list them with their prices
int [] processor = new int [] { };
int [] ram = new int [] {};
int [] HDD = new HDD [] {};
int [] disk = new disk[] {};
int sum = 0;
for (int i = 0; i < userSelection.length; i++)
{
sum += userSelection[i];
}
return sum;
} // end of getSum method
//start main method
public static void main(String[] args)
{
//declare array
int [] userSelection;
//initialize array
userSelection = new int[4];
DisplayInstructions();
notebookOrDesktop();
processor();
ram();
diskSize();
DriveOption();
DisplayResults();
//Processor
} // end of main
} // end of computer class