Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #define MAX_WEIGHT 3.0 using namespace std; // function prototypes float get_Price; float get_Weight(); void postage(float, float); // start main function int main() { float

#include #define MAX_WEIGHT 3.0 using namespace std;

// function prototypes float get_Price; float get_Weight(); void postage(float, float);

// start main function int main() { float weight == 0; // should not more than 3 kg float price = 0; // should > 0

weight = get_weight(); price = get_Price();

cout << "Price not including postage = " << price << " ";

// The postage function should able calculate and set price // which including postage cost postage(price, weight);

cout << "Total price including postage = " << price << ' ';

return 0; }

// start new user-defined functions float get_price() { float p = 0;

cout << " "; while (p == 0) { cout << "Item price (RM): "; cin >> p; }

return p; }

void get_Weight() { float w = 0;

do { cout << "Item weight (not more than 3 kg): "; cin >> w; } while (w <= 0 && w > MAX_WEIGHT);

return w; }

// weight more than 2 kg postage cost is RM 10 // weight 1 - 2 kg postage cost is RM 7 // weight less than 1 kg postage cost is RM 4 void postage(float p, float w) { float post = 0;

if (w >= 2) { post = 10; } else if (w > 1) { post = 7; } else { post = 4; }

cout << "Postage cost = " << post << " "; p += post; }

//please depug it

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 Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

2.3 Define human resource ethics.

Answered: 1 week ago