Question

write a c++ program that prompts the user to enter the shipement weight in kilograms and...

write a c++ program that prompts the user to enter the shipement weight in kilograms and the distance to the shipment destination, the program reads the weight and distance, calculate the shipment cost, displays this cost on the screen, invalid disply if the distance is in negetive, shipmennt rate per kg

distance

more than 1000 rate = 20

between 500 and 1000 rate = 15

between 0-500 rate = 10

less than 0 rate = --

Homework Answers

Answer #1

#include<stdio.h>
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
   float weight;
   int distance;
   cout << "\n Shippment Rate Per kg";
   cout<<"\n -----------------------";
   cout << "\n Distance Shipment Charges";
   cout << "\n____________________________________";
   cout << "\n More than 1000 km 20";
   cout << "\n Between 500 and 1000 km 15";
   cout << "\n Between 0 and 500 km 10";
   cout << "\n Less then 0 km Nil";
   cout << "\n____________________________________";   
   cout << "\n Enter the weight in Kilograms: ";
   cin >> weight;
   cout<<"\n Enter the Distance to the Shipment Destination:";
   cin>>distance;
   if(distance >= 1000)
   {
   float ship_cost = (20 * weight)/distance;
   printf("\n The Rate is:20");
   printf("\n Total cost = %f",ship_cost);
   }
   else
   if(distance >=500 && distance < 1000)
   {
   float ship_cost = (15 * weight)/distance;
   printf("\n The Rate is: 15");
   printf("\n Total cost = %f", ship_cost);
   }
   else
   if(distance >=0 && distance <500)
   {
   float ship_cost = (10 * weight)/distance;
   printf("\n The Rate is : 10");
printf("\n Total cost = %f",ship_cost);
   }
   else
   printf("\n Invalid Display ");
   return(0);
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a program that prompts the user to enter the weight of a person in kilograms...
Write a program that prompts the user to enter the weight of a person in kilograms and outputs the equivalent weight in pounds. (Note that 1 kilogram 52.2 pounds.) Add your name and comments to the .cpp page    Print your name on screen    Submit .cpp file
Write a program that prompts the user to enter an integer number between 1 and 999....
Write a program that prompts the user to enter an integer number between 1 and 999. The program displays the sum of all digits in the integer if the input is valid; otherwise, it displays a message indicating that the integer is not between 1 and 999 and hence, is invalid. Name the program file Q1.cpp Example: if the user enters 12, sum of digits is 3. If the user enters 122, sum of digits is 5.
In Python only. Write a program that prompts the user to enter a hex character and...
In Python only. Write a program that prompts the user to enter a hex character and displays its corresponding decimal integer.
Write a complete program that prompts the user to enter the number of students and each...
Write a complete program that prompts the user to enter the number of students and each student’s score, then finally displays the highest score.(in C++)
Write a program that prompts the user to enter a string and displays the number of...
Write a program that prompts the user to enter a string and displays the number of characters it contains, fourth character, and last character. Note: The string may contain blanks. For example: “C++ programming is fun”. You should write a complete program.
Write a program that prompts the user to enter time in 12-hour notation. The program then...
Write a program that prompts the user to enter time in 12-hour notation. The program then outputs the time in 24-hour notation. Your program must contain three exception classes: invalidHr, invalidMin, and invalidSec. If the user enters an invalid value for hours, then the program should throw and catch an invalidHr object. Follow similar conventions for the invalid values of minutes and seconds. This needs to be done in C++ There needs to be a separate header file for each...
Write a complete C program that prompts the user for the coordinates of two 3- D...
Write a complete C program that prompts the user for the coordinates of two 3- D points ( x1 , y1 , z1 ) and ( x2 , y2 , z2 ) and displays the distance between them computed using the following formula: distance= square root of (x1-x2)2+(y1-y2)2+(z1-z2)2
Write a program that prompts the user to enter the currency exchange between US dollars and...
Write a program that prompts the user to enter the currency exchange between US dollars and the Chinese renminbi. prompt the user to enter 0 to convert from us dollars to Chinese RMB and 1 for vice versa. Prompt the user to enter the amount in US dollars or Chinese RMB to convert it to Chinese RMB or US dollars, respectively, Sample Run: Enter the exchange rate from dollars to RMB: 6.58 Enter 0 to convert dollars to RMB and...
Modify the program so that it prompts the user to enter an entire line, reads the...
Modify the program so that it prompts the user to enter an entire line, reads the line, then echoes the entire line. Read only one byte at a time from the keyboard.Explain what you did. #include int main(void) { char aLetter; write(STDOUT_FILENO, "Enter one character: ", 21); // prompt user read(STDIN_FILENO, &aLetter, 1); // one character write(STDOUT_FILENO, "You entered: ", 13); // message write(STDOUT_FILENO, &aLetter, 1); // echo character return 0; }
Write a C program that prompts the user to enter a line of text on the...
Write a C program that prompts the user to enter a line of text on the keyboard then echoes the entire line. The program should continue echoing each line until the user responds to the prompt by not entering any text and hitting the return key. Your program should have two functions, writeStr and readLn, in addition to the main function. The text string itself should be stored in a char array in main. Both functions should operate on NUL-terminated...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT