Hello guys, can someone tell me whats wrong with my program, thanks a lot
#include <iostream>
using namespace std;
double totalPrice(char, int);
int main ()
{
char types [3]={'S','M','C'};
int price[3]={8,13,11};
int quantity;
double totalcost;
cout<<"Types of Sandwich Price (RM) " <<endl;
cout<< "Spicy(S) 8.00"<<endl;
cout<< "Meatball(M) 13.00"<<endl;
cout<<"Chicken (C) 11.00" <<endl;
cout << "Please enter types of sandwich you prefer : " << endl;
cin >> types;
cout << "Please enter quantity for the sandwich : " << endl;
cin >> quantity;
totalcost = totalPrice(types,quantity);
cout << "Total cost = " << totalcost << endl;
}
double totalPrice (char x, int y) //noneed semicolon due to function definition
{
double totalPrice,quantity, jumlahsemua;
if (x = 'S' )
totalPrice = y * 8;
else if (x ='M')
totalPrice = y * 13;
else if (x ='C')
totalPrice = y * 11;
jumlahsemua = totalPrice;
return jumlahsemua;
}
Bookmarks