Question

In: Computer Science

Create a CodeBlocks project with a main.cpp file. Submit the main.cpp file in Canvas. C++ Language...

Create a CodeBlocks project with a main.cpp file. Submit the main.cpp file in Canvas. C++ Language

A Game store sells many types of gaming consoles. The console brands are Xbox, Nintendo, PlayStation.

A console can have either 16 or 8 gigabytes of memory.

Use can choose the shipping method as either Regular (Cost it $5) or Expedite (Cost is $10)

The price list is given as follows:

Memory size/Brand Xbox Nintendo PlayStation

16 gigabytes 499.99 469.99 409.99

8 gigabytes 419.99 379.99 339.99

Determine the price of a given console dependent on the user inputs. The sales tax is 9.75% for each console.

Validation:

For the brand name, use input can be X for Xbox, N for Nintendo or P for PlayStation in upper letter case only.

For memory size user input can only be 8 or 16.

The input quantity should be 0 or positive, but must not exceed 20.

The shipping method can only be R or E.

If any user input is not correct, display an error message and skip all calculation.

Print the brand name and the quantity in the price calculation, for example with 16 gigabytes:

The item price for (2 x Xbox) is $999.98

All currency amounts should be displayed with 2 digits in decimal fraction.

There is No need to use a loop for repetition.

Here are several separate program sample runs.


Welcome to the Game store.

Enter the brand name of the game console (X for Xbox, N for Nintendo, P for PlayStation): X

Enter the memory size of the game console (8 or 16 gigabytes): 16

Enter quantity to buy: 2

The item price for (2 x Xbox) is $999.98

The sale tax is $ 97.50

Enter shipping method (R for Regular, E for Expedite): R

Shipping cost is $5.00

The total bill is $1102.48

----------------------

Solutions

Expert Solution

#include <iostream>
using namespace std;

double round(double var) 
{ 
    double value = (int)(var * 100 + .5); 
    return (double)value / 100; 
} 

int main()
{
    char console,shipping,index=-1;
    int GB,quantity;
    double price,tax,shipcost;
    double eightGB[] = {419.99, 379.99, 339.99};
    double sixteenGB[] = {499.99, 469.99, 409.99};
    cout<<"Enter the brand name of the game console (X for Xbox, N for Nintendo, P for PlayStation):";
    cin>>console;
    switch(console){
        case 'X':
            index = 0;
            break;
        case 'N':
            index = 1;
            break;
        case 'P':
            index = 2;
            break;
        default:
            cout<<"Please enter valid input";
            exit(0);
    }
    cout<<"Enter the memory size of the game console (8 or 16 gigabytes):";
    cin>>GB;
    cout<<"Enter quantity to buy:";
    cin>>quantity;
    if(GB!=8 || GB!=16){
        cout<<"Please enter valid input";
        exit(0);
    }
    if(quantity<0 && quantity>20){
        cout<<"Please enter valid input";
        exit(0);
    }
    if(GB==8){
        price = eightGB[index]*quantity;
    }else if(GB==16){
        price = sixteenGB[index]*quantity;
    }
    cout<<"The item price for ("<<quantity<<" x Xbox) is $"<<price;
    tax = round(price*0.0975);
    cout<<"\nThe sale tax is $"<<tax;
    cout<<"\nEnter shipping method (R for Regular, E for Expedite):";
    cin>>shipping;
    if(shipping=='R'){
        cout<<"Shipping cost is $5.00";
        shipcost = 5.00;
    }else if(shipping=='E'){
        cout<<"Shipping cost is $10.00";
        shipcost = 10.00;
    }
    cout<<"\nThe total bill is $"<<(price+tax+shipcost);
    return 0;
}

Related Solutions

Using C++ 1. Create a main function in a main.cpp file. The main function should look...
Using C++ 1. Create a main function in a main.cpp file. The main function should look as follows int main() {return 0;} 2. Create an array. 3. Ask user to enter numbers in size of your array. 4. Take the numbers and store them in your array. 5. Go through your array and add all the numbers. 6. Calculate the average of the numbers. 7. Display the numbers, sum and average.
Please use C language to code all of the problems below. Please submit a .c file...
Please use C language to code all of the problems below. Please submit a .c file for each of the solutions, that includes the required functions, tests you wrote to check your code and a main function to run the code. Q2. Implement the quick-sort algorithm.
C Language NO ARRAY UTILIZATION OR SORTING Create a .txt file with 20 integers in the...
C Language NO ARRAY UTILIZATION OR SORTING Create a .txt file with 20 integers in the range of 0 to 100. There may be repeats. The numbers must not be ordered/sorted. The task is to find and print the two smallest numbers. You must accomplish this task without sorting the file and without using arrays for any purpose. It is possible that the smallest numbers are repeated – you should print the number of occurrences of the two smallest numbers....
Create a project that gets input from the user. ( Name the project main.cpp) Ask the...
Create a project that gets input from the user. ( Name the project main.cpp) Ask the user for a value for each side of the triangle. Comment your code throughout. Include your name in the comments. Submit the plan-Psuedo code (include Flowchart, IPO Chart) and the desk check with each submission of your code. Submit the plan as a pdf. Snips of your output is not a plan. Save the plan and desk check as a pdf Name the code...
(1) Create three files to submit. ContactNode.h - Class declaration ContactNode.cpp - Class definition main.cpp -...
(1) Create three files to submit. ContactNode.h - Class declaration ContactNode.cpp - Class definition main.cpp - main() function (2) Build the ContactNode class per the following specifications: Parameterized constructor. Parameters are name followed by phone number. Public member functions InsertAfter() (2 pts) GetName() - Accessor (1 pt) GetPhoneNumber - Accessor (1 pt) GetNext() - Accessor (1 pt) PrintContactNode() Private data members string contactName string contactPhoneNum ContactNode* nextNodePtr Ex. of PrintContactNode() output: Name: Roxanne Hughes Phone number: 443-555-2864 (3) In main(),...
(1) Create three files to submit: ItemToPurchase.h - Class declaration ItemToPurchase.cpp - Class definition main.cpp -...
(1) Create three files to submit: ItemToPurchase.h - Class declaration ItemToPurchase.cpp - Class definition main.cpp - main() function Build the ItemToPurchase class with the following specifications: Default constructor Public class functions (mutators & accessors) SetName() & GetName() (2 pts) SetPrice() & GetPrice() (2 pts) SetQuantity() & GetQuantity() (2 pts) Private data members string itemName - Initialized in default constructor to "none" int itemPrice - Initialized in default constructor to 0 int itemQuantity - Initialized in default constructor to 0 (2)...
URGENT: USING C++: You are given a main.cpp and a Schedule.h file. You are to write...
URGENT: USING C++: You are given a main.cpp and a Schedule.h file. You are to write a Schedule.cpp file that implements the missing pieces from Schedule.h. // ************************************ // ************* main.cpp ************ // ************************************ #include "Schedule.h" void main() { Schedule s1(10); s1.addEntry(1,20,"Feed Cat"); s1.addEntry(2,40,"Feed Dog"); s1.addEntry(2,50,"Walk Dog"); s1.addEntry(4,0, "Fix Dinner"); s1.addEntry(5,15,"Eat Dinner"); s1.printSchedule(); Schedule s2(s1); // Note this uses the copy constructor cout << endl << "Output from s2 " << endl; s2.printSchedule(); } // ********************************************** // ************* Schedule.h ******************...
c++ language Create a file program that reads an int type Array size 10; the array...
c++ language Create a file program that reads an int type Array size 10; the array has already 10 numbers, but your job is to resize the array, copy old elements of array to the new one and make it user input and add an additional 5 slots in the array, and lastly do binary search based on user input. close the file.
Please answer the problem below in C programming language: Create a pointer activity source file -...
Please answer the problem below in C programming language: Create a pointer activity source file - cptr2.c - that takes two arguments, a number from 1 to 3, and a string sentence(s). Create variables for a character, an integer, a string pointer. Based on integer value you will use that number of string pointers. The string variable is a string pointer that has not been allocated.    Define pointers to those variables types without any initialization of those points to the...
In PowerShell ISE create a script. Use the text file “its3410Users.txt” (found on Canvas) and import...
In PowerShell ISE create a script. Use the text file “its3410Users.txt” (found on Canvas) and import the users into your domain controller. The user file has a first name, last name, and department. Using this information, create users with the following specifications: Username will be first name.last name User Principal Name will be first name.last [email protected] The department signifies the OU that the user will be placed into If the department does not exist, create it Fill in the first...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT