160k views
1 vote
Add the 3 program comments at the top of the program with the information needed:

Name:
Date:
Program:
Set appropriate variables for the maximum and minimum order amounts
Set an appropriate variable for the price per pound of 7.99
Get the order amount input and cast to a number and store it in a variable (Since it can contain decimals, what kind of number cast should you use?)
Write an if structure that compares the input value with the minimum and maximum values according to the creiteria below:
if over the maximum of 100 return a message indicating that
if under minimum of 0.25 return a message indicating that
if within the allowed range return a message with the calculated price rounded to 2 decimal places!
Test your program extensivel and compare with the example output below

Add the 3 program comments at the top of the program with the information needed: Name-example-1
User Araqnid
by
4.8k points

1 Answer

4 votes

C++:

#include <bits/stdc++.h>

typedef long double d;

int main(int argc, char* argv[]) {

d a=0.25,b=100,c;

std::cout << "Enter amount: "; std::cin>>c;

if(c>b) std::cout << "Huge amount!";

else if(c<a) std::cout << "Insufficient amount!";

else std::cout << "The price is: $" << std::ceil((c*7.99)*100.0)/100.0 << std::endl;

return 0;

}

For Python code, check the attachments.

Add the 3 program comments at the top of the program with the information needed: Name-example-1
User Aakash Verma
by
4.3k points