Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

java Programming Problem Using the web sites of various computer vendors of your

ID: 3662600 • Letter: J

Question

java Programming Problem

Using the web sites of various computer vendors of your choice, pick a computer that would satisfy the needs of an average college student, and collect all characteristics of the computer that you consider interesting, including the price. Write a program that displays the defining characteristics of the computer in a format that would attract potential users.

Continue your exercise by simulating an upgrade for the computer chosen earlier. Choose a better processor, more RAM, a different hard disk drive, an audio card, a video card, and speakers. Find prices for all the components mentioned above. Continue your program, defining appropriate variables for the new components, and the price of the new, upgraded computer. Read all prices from the user, and calculate the price of the new computer. Display the new configuration, with all the characteristics defined earlier, as well as the price.

Explanation / Answer

import java.util.Scanner; public class Problem1 { public static void main(String[] args) { // Display parts and prices for student computer System.out.println("Hey there! Let's take a look at your current computer. "); System.out.println("Model: Alienware X51 Desktop "); // All are based on Newegg.com prices String cpu = "Intel Core i3-3250"; double cpuPrice = 149.99; String ram = "Corsair XMS 8GB"; double ramPrice = 79.99; String hddrive = "Western Digital 750GB"; double hddrivePrice = 120.31; String audiocard = "Onboard Audio"; double audiocardPrice = 0.00; String gpu = "AMD Radeon HD 7750"; double gpuPrice = 99.99; String speakers = "Logitech X-140 Speakers"; double speakersPrice = 29.99; double total = cpuPrice + ramPrice + hddrivePrice + audiocardPrice + gpuPrice + speakersPrice; // printf() formats the components and prices into readable columns System.out.printf("%-25s %-25s %-25s ", "Component", "Component Type", "Price"); System.out.printf("%-25s %-25s $%-25.2f ", cpu, "CPU", cpuPrice); System.out.printf("%-25s %-25s $%-25.2f ", ram, "RAM", ramPrice); System.out.printf("%-25s %-25s $%-25.2f ", hddrive, "Hard Drive", hddrivePrice); System.out.printf("%-25s %-25s $%-25.2f ", audiocard, "Audio Card", audiocardPrice); System.out.printf("%-25s %-25s $%-25.2f ", gpu, "Video Card", gpuPrice); System.out.printf("%-25s %-25s $%-25.2f ", speakers, "Speakers", speakersPrice); System.out.printf("Your current computer costs: $%.2f ", total); System.out.println(" Not bad. Let's upgrade your computer a little bit. Here are some upgrades that I recommend. " + "You can enter the current market prices yourself: "); // set new part names for recommended upgrades; prices are from Newegg.com / Amazon.com String cpuNew = "Intel Core i7-4770K"; // $339.99 String ramNew = "G.Skill Ripjaws Z 32GB"; // $314.99 String hddriveNew = "Samsung 840 EVO 1TB"; // $599.99 String audiocardNew = "Creative Sound Blaster Zx"; // $119.99 String gpuNew = "AMD Radeon R9 290X"; // $649.99 String speakersNew = "Logitech z-5500 Speakers"; // $749.99 // ask user for market prices on recommended parts Scanner input = new Scanner(System.in); System.out.printf("Price for %s: ", cpuNew); double cpuPriceNew = input.nextDouble(); System.out.printf("Price for %s: ", ramNew); double ramPriceNew = input.nextDouble(); System.out.printf("Price for %s: ", hddriveNew); double hddrivePriceNew = input.nextDouble(); System.out.printf("Price for %s: ", audiocardNew); double audiocardPriceNew = input.nextDouble(); System.out.printf("Price for %s: ", gpuNew); double gpuPriceNew = input.nextDouble(); System.out.printf("Price for %s: ", speakersNew); double speakersPriceNew = input.nextDouble(); double totalNew = cpuPriceNew + ramPriceNew + hddrivePriceNew + audiocardPriceNew + gpuPriceNew + speakersPriceNew; input.close(); // display new part names and prices, and calculate the total costs for upgraded PC System.out.printf(" %-27s %-25s %-25s ", "Upgraded Component", "Component Type", "Price"); System.out.printf("%-27s %-25s $%-25.2f ", cpuNew, "CPU", cpuPriceNew); System.out.printf("%-27s %-25s $%-25.2f ", ramNew, "RAM", ramPriceNew); System.out.printf("%-27s %-25s $%-25.2f ", hddriveNew, "Hard Drive", hddrivePriceNew); System.out.printf("%-27s %-25s $%-25.2f ", audiocardNew, "Audio Card", audiocardPriceNew); System.out.printf("%-27s %-25s $%-25.2f ", gpuNew, "Video Card", gpuPriceNew); System.out.printf("%-27s %-25s $%-25.2f ", speakersNew, "Speakers", speakersPriceNew); System.out.printf(" Your newer, beast computer costs $%,.2f and rocks the socks off " + "of your old one. We should name it "Godzilla". ", totalNew); } }