132k views
2 votes
c.Task 3: an application program where the user enters the price of an item and the program computes shipping costs. If the item price is $100 or more, then shipping is free otherwise it is 2% of the price. The program should output the shipping cost and the total price.

1 Answer

2 votes

Answer:

//Program is written in C++ language

// Comments explains difficult lines

#include<iostream>

using namespace std;

int main (){

//Variable declaration

double price, shipping;

cout<<"Item Price: ";

cin>>price;

//Test price for shipping fee

shipping = 0; //Initialise shipping fee to 0 (free)

if(price <100)

{

shipping = 0.2 * price;

}

//The above if statement tests if item price is less than 100.

//If yes, then the shipping fee is calculated as 20% of the item price

//Else, (if item price is at least 100), shipping fee is 0, which means free

if(shipping != 0)

{

cout<<"Shipping fee is "<<shipping;

}

else

{

cout<<"Item will be shipped for free";

}

return 0;

}

User Yariv
by
5.1k points