Question

In: Computer Science

C# assignment 5: Shipping Charges A large Internet merchandise provider determines its shipping charges based on...

C# assignment 5: Shipping Charges
A large Internet merchandise provider determines its shipping charges based on the number of items purchased. As the number increases, the shipping charges proportionally decrease. This is done to encour- age more purchases. If a single item is purchased, the shipping charge is $2.99. When customers purchase between 2 and 5 items, they are charged the initial $2.99 for the first item and then $1.99 per item for the remaining items. For customers who purchase more than 5 items but less than 15, they are charged the initial $2.99 for the first item, $1.99 per item for items 2 through 5, and $1.49 per item for the remaining items. If they purchase 15 or more items, they are charged the initial $2.99 for the first item, $1.99 per item for items 2 through 5, and $1.49 per item for items 6 through 14, and then just $0.99 per item for the remaining items. Allow the user to enter the number of items purchased. Define appropriate constants, use the decimal data type, and display the ship- ping formatted charges.

Solutions

Expert Solution

C# Code:

using System;

class Program
{
   //Defining constants
    public const double item_1 = 2.99;
    public const double item_2_5 = 1.99;
    public const double item_6_14 = 1.49;
    public const double item_15 = 0.99;
  
   //Main method
    static void Main()
    {
        int numItems;
        double shippingCharges = 0.0;
      
        //Reading number of items
        Console.Write("Enter number of items purchased: ");
        numItems = Convert.ToInt32(Console.ReadLine());
      
       //For single item
        if (numItems == 1)
        {
            shippingCharges = item_1;
        }
      
       //Items greater than 1 and less than or equal to 5
        else if (numItems > 1 && numItems <= 5)
        {
            shippingCharges = item_1 + ((numItems-1) * item_2_5);
        }
      
       //Items greater than 5 and less than or equal to 14
       else if (numItems > 5 && numItems < 15)
        {
            shippingCharges = item_1 + (item_2_5*4) + ((numItems-5)*item_6_14);
        }
      
       //Items greater than or equal to 15
       else if (numItems >= 15)
        {
            shippingCharges = item_1 + (item_2_5 * 4) + (item_6_14 * 9) + ((numItems - 14) * item_15);
        }
      
       //Printing result
       Console.Write("\nShipping Charges: ${0:F2}", shippingCharges);
    }
}


_____________________________________________________________________________________________

Sample Run:


Related Solutions

The Internet is made of a large number of networks. Their arrangement determines the topology of...
The Internet is made of a large number of networks. Their arrangement determines the topology of the Internet. Find out about the topology of the Internet and write short report summarizing your findings.
This C++ assignment asks to write a function that determines if a C-string begins with a...
This C++ assignment asks to write a function that determines if a C-string begins with a specified prefix. It should have the following signature: bool starts(char *str, char *prefix) It should return true if str begins with prefix, false if not. It should return false if prefix is longer than str. See the table below for some examples of what your function should return for various cases: str prefix returns airplanes air true airplanes abc false airplanes plane false airplanes...
5. If the buyer of merchandise agrees to pay shipping costs, how is the cost recorded?...
5. If the buyer of merchandise agrees to pay shipping costs, how is the cost recorded? 6. If the seller of merchandise agrees to pay shipping costs, how is the cost recorded? 7. Why would the seller of merchandise offer a discount for early payment? 8. Payment terms are: 4/10, n/50. What does this mean? 9. If the buyer takes advantage of the discount offered, what will happen to the cost of his/her merchandise? 10. When would the contra revenue...
A TV satellite provider charges $42 a month for its basic service package. Its variable costs...
A TV satellite provider charges $42 a month for its basic service package. Its variable costs are $4 a month per account. The company spends $24 a year per account on marketing with an attrition rate of 1% a month. Assuming an annual discount rate of 5%, calculate the maximum amount that this company could spend to acquire a new customer and still provide a positive expected contribution. Please show the work as I’m trying to learn the concept
Write a program In C to compute internet charges according to a rate schedule. The rate...
Write a program In C to compute internet charges according to a rate schedule. The rate schedule is as follows: $0.08 per GB for usage between 0 and 40 GB, inclusive $0.07 per GB for usage between 41 GB and 70 GB, inclusive $0.05 per GB for usage between 71 GB and 110 GB, inclusive $0.04 per GB for usage greater than 110 GB Learning Objectives In this assignment, you will: Use a selection control structure Use a repetition control...
Subject is C++ Write a program to compute internet charges according to a rate schedule. The...
Subject is C++ Write a program to compute internet charges according to a rate schedule. The rate schedule is as follows: $0.08 per GB for usage between 0 and 40 GB, inclusive $0.07 per GB for usage between 41 GB and 70 GB, inclusive $0.05 per GB for usage between 71 GB and 110 GB, inclusive $0.04 per GB for usage greater than 110 GB code must use these four functions, using these names (in addition to main): getData computeCharges...
C++ For the assignment, we will use the previous assignment’s program that determines whether a college...
C++ For the assignment, we will use the previous assignment’s program that determines whether a college class room is in violation of fire law regulations regarding the maximum room capacity and add more logic to that program. We will need to make the following enhancements… For each new class entry that is taken, you will write out the information to a file. The file can be any .txt file name of your choosing. The file should be appended to each...
C++ For the assignment, we will use the previous assignment’s program that determines whether a college...
C++ For the assignment, we will use the previous assignment’s program that determines whether a college class room is in violation of fire law regulations regarding the maximum room capacity and add more logic to that program. We will need to make the following enhancements… Convert all of the function’s parameters from pass by value to pass by reference. Accumulate totals for each of the class rooms that we are using for this program. When the program ends (user choice...
C++ For the assignment, we will use the previous assignment’s program that determines whether a college...
C++ For the assignment, we will use the previous assignment’s program that determines whether a college class room is in violation of fire law regulations regarding the maximum room capacity and add more logic to that program. We will need to make the following enhancements… Convert all of the function’s parameters from pass by value to pass by reference. Accumulate totals for each of the class rooms that we are using for this program. When the program ends (user choice...
9. An internet provider wants to estimate the proportion of its existing customers that would sign...
9. An internet provider wants to estimate the proportion of its existing customers that would sign up to their new streaming service for movies, tv shows etc. Several sampling strategies have been proposed. An internet provider wants to estimate the proportion of its existing For each of these proposed sampling strategies, indicate what type of sampling method is used and what biases, if any, may result. a) Randomly select one street in each city which has many users of this...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT