Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4. Write the exact output of the following code. int num = 10; //Line 1 double temp = 4.59; //Line 2 bool found; //Line 3

4. Write the exact output of the following code.

int num = 10; //Line 1 double temp = 4.59; //Line 2 bool found; //Line 3 found = (num == 2 * static_cast(temp) + 2); //Line 4 cout << "The value of found is: " << found << endl; //Line 5

5. Program specification: if the number of items bought is less than 5, then the shipping charges are $5.00 for each item bought; if the number of items bought is at least 5, but less than 8, then the shipping charges are $4.00 for each item bought; if the number of items bought is at least 8, there are no shipping charges. Correct the following code so that it computes the correct shipping charges. I am only looking for this section of code after it has been fixed, but you can certainly show an entire program if you'd like (in which case I encourage you to test numOfItemsBought values of 4, 5, 7, 8, and 100).

if (numOfItemsBought >> 5) shippingCharges = 5.00 * numOfItemsBought; else if (5 numOfItemsBought && numOfItemsBought is less than 8); shippingCharges = 4.00 * numOfItemsBought; else shippingCharges = 0.00;

6. Suppose that overSpeed and fine are double variables. To give some context, if you're caught speeding doing 65.0 miles per hour in a 60.0 mph highway zone then overSpeed would be 65.0-60.0=5.0. Write C++ code which assigns the value to fine as follows:

  • If overspeed is above zero and less than 5, the value assigned to fine is $20.00
  • If overSpeed is at least 5 and less than 10, the value assigned to fine is $70.00
  • If overSpeed is at least 10 and less than 15, the value assigned to fine is $120.00
  • If overSpeed is at least 15 the value assigned to fine is $130.00 +(10*(overSpeed - 15))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David Kroenke

11th Edition

0132302675, 9780132302678

More Books

Students also viewed these Databases questions

Question

83 Change management methods.

Answered: 1 week ago