Starting from:

$29.99

Homework 03: Selection Solution

Goals
Get familiar with ​boolean​ expressions
Get familiar using ​if-then-else​ statements
Get familiar using ​switch​ statements
Introduction
The types of programs you currently have the ability to create must strictly adhere to just one possible path of execution. This means that your programs can really do only one type of action or calculation, such as generating a username or displaying the area of a triangle. Selection, using ​if-then-else​ and/or ​switch​ statements, opens up a new world of possibilities by allowing a computer to evaluate one or more conditions, then act on them.

 

For instance, instead of making separate programs to let a user calculate the area of circles, triangles, and squares, you can now build all of that functionality into one program, and present the user with a menu to choose from. You will experiment with the use of selection to determine menu choices below.

 

Description
 

For this homework, your task is to create a program that prompts a user for their choice of processor, memory, storage, graphics, and mouse or trackpad. The program should then display the total price of the desktop computer with the desired specifications. Since we are dealing with money, please display the total price with two decimal places.

 

Note that the starting price of the desktop to be customized is ​4999.0​. The pricing is based off of the machine ​here​. Please use the example output below to see how your program should look. The output you get on your screen should match that in the picture — please be careful with typos. Below is the cost to be added for each component.

 

 Upgrade costs

 

Processor

 

Component
Additional cost
8-core Intel Xeon W
0.0
10-core Intel Xeon W
800.0
14-core Intel Xeon W
1600.0
18-core Intel Xeon W
2400.0
 

Memory

 

Component
Additional cost
32GB DDR4 RAM
0.0
64GB DDR4 RAM
800.0
128GB DDR4 RAM
2400.0
 

Storage

 

Component
Additional cost
1TB SSD
0.0
2TB SSD
800.0
4TB SSD
2800.0
 

Graphics

 

Component
Additional cost
Radeon Pro Vega 56
0.0
Radeon Pro Vega 64
600.0
 

 

Mouse or Trackpad

 

Component
Additional cost
Mouse
0.0
Trackpad
50.0
Both
149.0
 

Example output
 

 

 

 

 

Requirements
 

You are required to create one class, ​ComputerCustomizer​, that follows the specifications outlined above. It is to be held in a file called ​ComputerCustomizer.java​. For this homework, you can assume that the user will only enter a valid menu choice.

 

More products