Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function computer-price ) that takes the following arguments, in this order, and computes the price of a computer: 1. cpu: the manufacturer of
Write a function computer-price ) that takes the following arguments, in this order, and computes the price of a computer: 1. cpu: the manufacturer of the CPU, which must be "Intel" or "AMD" (capitalized just so) 2. ghz: the gigahertz rating of the CPU, which must be a positive number 3. disk-type: the disk type, which must be SSD" or "HDD" (capitalized just so) 4. disk.size: the disk's size in gigabytes, which must be a positive number The base price of the computer is $1000. Components add to the computer's price as follows An Intel processor adds $200 An AMD processor adds $175 A CPU running at 2 GHz or higher adds $150 A CPU running at 1 GHz or higher (but less than 2 GHz) adds $80 A solid state disk (SSD) adds $225 A hard disk (HDD) adds $100 Each gigabyte of disk space costs $2. Based on the computer's specifications, the function computes and returns the computer's price. If any of the four arguments is invalid, the function returns the floating-point number -1.0 Examples: Return Value Function Call computer price 'AMD', -0.1, 'hdd', 16.7) computer-price 'Intel', 0.0, 'SSD, 86.0) computer price 'AMD', 3.5, HDD',53.8) computer price 'Intel', -0.1, 'HDD',44.5)-1.0 computer price 'AMD', 1.4, HDD', 1.8) computer price 'Intel', 2.8, SSD, 62.0) 1699.0 computer price ('intel', 1.1, 'SSD, 82.5) computer price 'AMD', 3.3, SSD',63.9) computer price 'AMD', 3.4, HDD', 48.8) computer price ('Intel', 2.3, ssd', 97.9)-1.0 1.0 1532.6 1358.6 1.0 1677.8 1522.6
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started