Answer to Question #217575 in C++ for kojo

Question #217575

A drink costs 2 dollars. A taco costs 4 dollars. Given the number of each, compute total cost and assign totalCost with the result. Ex: 4 drinks and 6 tacos yields totalCost of 32.

#include <iostream>

using namespace std;

int main() {

  int numDrinks;

  int numTacos;

  int totalCost;

  cin >> numDrinks;

  cin >> numTacos;

  /* Your solution goes here */

  cout << "Total cost: " << totalCost << endl;

  return 0;

}

1
Expert's answer
2021-07-16T10:25:56-0400
#include <iostream>


using namespace std;


int main() {


	int numDrinks;
	int numTacos;
	int totalCost;
	cin >> numDrinks;
	cin >> numTacos;


	/* Your solution goes here */
	totalCost=numDrinks*2+numTacos*4;
	cout << "Total cost: " << totalCost << endl;


	return 0;
}




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS