175k views
5 votes
A hotdog stand sells hotdogs, potato chips and sodas. Hotdogs are $2.50 each. Potato chips are $1.50 per bag. Sodas are $1.25 per cans. Design a program to do the following. Ask the user to enter number of hotdogs, chips and sodas ordered by the customer. The program will calculate and display the total amount due.

User Bugsyb
by
4.8k points

1 Answer

1 vote

Answer:

// here is code in c++.

#include <bits/stdc++.h>

using namespace std;

int main() {

// initialize the price of a unit of each product

float hot_dog=2.5,p_chips=1.5,soda=1.25;

// variables to read numbers of each product

int num_hot_dog,num_p_chips,num_soda;

cout<<"enter the number of hot dogs:";

// read the number of hot dogs

cin>>num_hot_dog;

cout<<"enter the number of potato chips:";

//read the number of potato chips

cin>>num_p_chips;

cout<<"enter the number of soda can:";

// read the number of soda cans

cin>>num_soda;

// calculate total amount

float total=(num_hot_dog*hot_dog)+(p_chips*num_p_chips)+(soda*num_soda);

// print the total amount due

cout<<"total amount is :"<<total<<endl;

return 0;

}

Step-by-step explanation:

Initialize price of a unit of each product. Declare variables to read number of each item.Read the number of each item from user and store them.Then multiply them with their unit price.Add all of them, it will give total amount due.

Output:

enter the number of hot dogs:5

enter the number of potato chips:3

enter the number of soda can:6

total amount is :24.5

User Chluebi
by
5.3k points