Question

AVE29.1: Using constants in expressions ACTIVITY The cost to ship a package is a flat fee of 75 cents plus 25 cents per pound. 1. Declare a const named CENTS_PER_POUND and initialize with 25. 2. Get the shipping weight from user input storing the weight into shipWeightPounds. 3. Using FLAT FEE CENTS and CENTS PER POUND constants, assign shipCostCents with the cost of shipping a package weighing shipWeightPounds. 1 #include <stdio.h> 3 int main(void) f 5 int shipCostcents e; 165 4 int shipheightPounds; 6 const int FLAT-FEE-CENTS = 75; 8Your solution goes here 10 printf(Weight(lb) : %d, Flat fee(cents): 5SsC %a, cents per pound: %d, Shipping cost (cents): %d\n, shipheightPounds, FLAT FEE CENTS, CENTS_ PER POUND, shipcostcents) 12 13 return e; 14

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <stdio.h>

int main() {
    int shipWeightPounds;
    int shipCostCents = 0;
    const int FLAT_FEE_CENTS = 75;
    const int CENTS_PER_POUND = 25;

    scanf("%d", &shipWeightPounds);

    shipCostCents = FLAT_FEE_CENTS + CENTS_PER_POUND * shipWeightPounds;

    printf("Weight(lb): %d, Flat fee(cents): %d, Cents per pound: %d, Shipping cost(cents): %d\n", shipWeightPounds,
           FLAT_FEE_CENTS, CENTS_PER_POUND, shipCostCents);

    return 0;
}
Add a comment
Know the answer?
Add Answer to:
AVE29.1: Using constants in expressions ACTIVITY The cost to ship a package is a flat fee...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Global Courier Services will ship your package based on how much it weighs and how far...

    Global Courier Services will ship your package based on how much it weighs and how far you are sending the package. (visual studio or dev c) You need to write a design tool and a program in C that calculates the shipping charge based on weight and distance and the total cost. The shipping rates are as follows: BASED ON WEIGHT Charge 10 dollars for all package weighing 10 pounds or less Charge an additional 2 dollars per pound for...

  • C++ IMPORTANT: Write a driver program (PackageDriver) that creates objects of each type of Package as...

    C++ IMPORTANT: Write a driver program (PackageDriver) that creates objects of each type of Package as pointers to a Package and cout the objects. Write a driver program (PackageDriver) that creates objects of each type of Package as pointers to a Package and cout the objects. Write a driver program (PackageDriver) that creates objects of each type of Package as pointers to a Package and cout the objects. Package-delivery services, such as FedEx®, DHL® and UPS®, offer a number of...

  • My program works fine with if else conditions but when it is not working when I...

    My program works fine with if else conditions but when it is not working when I try to implement it using a for loop. Can you fix my for loop and please show me how to do this using loops? I would appreciate if you could explain the loop that you are using. /* Programming Challenge: Shipping Charges The Fast Freight Shipping Company charges the following rates: Weight of Package (in Kilograms) Rate per 500 Miles Shipped 2 kg or...

  • please post ONLY flatratepackage.cpp, flateratepackage.h, package inventory.h and package inventory.cpp... Thank you! In this homework, you...

    please post ONLY flatratepackage.cpp, flateratepackage.h, package inventory.h and package inventory.cpp... Thank you! In this homework, you are going to write a program to represent various types of packages offered by package-delivery services. You need to create an inheritance hierarchy to represent various types of packages with different shipping options and associated costs. The base class is Package and the derived classes are FlatRatePackage and OvernightPackage. The base class Package includes the following attributes: • Sender information: senderName (string), senderAddress (string),...

  • Declare and initialize 4 Constants for the course category weights: The weight of Homework will be...

    Declare and initialize 4 Constants for the course category weights: The weight of Homework will be 15% The weight of Tests will be 35% The weight of the Mid term will be 20% The weight of the Fin al will be 30% Remember to name your Constants according to Java standards. Declare a variable to store the input for the number of homework scores and use a Scanner method to read the value from the Console. Declare two variables: one...

  • Need help with C++ assignment Assignment 1 and .txt files are provided at the bottom. PART...

    Need help with C++ assignment Assignment 1 and .txt files are provided at the bottom. PART A PART B Assignment 1 #include <iostream> #include <string> #include <fstream> #include <iomanip> #include <stdio.h> #include <ctype.h> #include <string.h> #include <algorithm> using namespace std; /** This structure is to store the date and it has three integer fields **/ struct Date{    int day;    int month;    int year; }; /** This structure is to store the size of the box and it...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT