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