Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have a question on what I\'m doing wrong here. I believe that I have all the p

ID: 3712512 • Letter: I

Question

I have a question on what I'm doing wrong here.

I believe that I have all the pieces made, but when I try and make them work together they do not do anything except hit the system("pause").

Here is what I have (instructions for the question are in the comments in the main file)


#pragma once

#include <iostream>

#include <iomanip>

using namespace std;

class Postage {

public:

void initialize();

int setWeight();

void sendEconomy(int weight, double price, double cost);

void sendPriority(int weight, double price, double cost);

void sendOvernight(int weight, double price, double cost);

void printInfo(void);

double itsPrice;

int weight;

double cost;

double Price;

private:

~Postage();

};

void Postage::initialize()

{

}

inline int Postage::setWeight()

{

do {

cout << "how much does your package weigh?" << endl << "Please enter the weight here: " << endl;

cin >> weight;

if (weight <= 70) {

cout << "you have entered " << weight << endl;

}

else if (weight >= 71 || weight <= 0) {

cout << "We do not ship items that are over 70 pounds. What do you think we are amazon? Try again: ";

cin >> weight;

}

} while (weight >= 70 || weight <= 0);

return weight;

}

void Postage::sendEconomy(int weight, double price, double cost)

{

weight = weight;

price = 2.00 + (weight * .40);

price = cost;

}

void Postage::sendPriority(int weight, double price, double cost)

{

weight = weight;

price = 5.00 + (weight * .50);

price = cost;

}

void Postage::sendOvernight(int weight, double price, double cost)

{

weight = weight;

price = 18.00 + (weight * 2.00);

price = cost;

}

void Postage::printInfo()

{

cout << fixed << setprecision(2) << cost;

cout << "Your total shipping cost is " << "$" << cost << endl;

}

Postage::~Postage()

{

}

/*

Create a class called Postage. Provide a function called setWeight to set the weight of a package in pounds. Packages cannot weigh more than 70 pounds. The sendEconomy function returns a price based on the formula: $2.00 plus 40 cents per pound. The sendPriorty function returns a price of $5.00 plus 50 cents per pound. The sendOvernight function returns a price of $18.00 plus $2.00 per pound.

Using the class from the prior question, write a main function that asks for the weight of a package and prints out the postal charges (Economy, Priority, and Overnight).

*/

#include <iostream>

#include <iomanip>

#include "Source.h"

using namespace std;

int main() {

int input;

int weight = 0;

cout << "How fast would you like to ship it?" << endl;

cout << "choose 1 to ship standard shipping" << endl;

cout << "choose 2 to ship priority shipping" << endl;

cout << "choose 3 to ship overnight shipping" << endl;

cout << "Please choose a shipping option: " << endl;

cin >> input;

switch (input) {

case 1:

int setWeight();

void initiailize();

void standard();

void printInfo();

void printMessage(void);

system("pause");

break;

case 2:

void initialize();

void priority();

void printInfo();

void printmessage();

system("pause");

break;

case 3:

void initialize();

void overnight();

void printInfo();

void printMessage();

system("pause");

break;

default:

cout << "You choose something I don't understand. We don't tolerate your wasting of time. Go away! " << endl;

break;

}

system("pause");

return 0;

}

Explanation / Answer

The code is fine but it is doing a very silly mistake. In the main function, there is no creation of any object of the postage class and thus nor are any methods called by that object which should be there .

Moreover , the names of the functions being called from the main and those which are defined in the postage class are also different . For example, the sendOvernight() function and the overnight() function. So, the program seems to be correct in blocks but can't be implemented for what it is designed to. Adding these minute changes will do the desired task.