Question

Question: A drink costs 5 dollars. A taco costs 7 dollars. Given the number of each,...

Question: A drink costs 5 dollars. A taco costs 7 dollars. Given the number of each, compute total cost and assign to totalCost. Ex: 2 drinks and 3 tacos yields totalCost of 31.

On my screen, there is a box below this question and it has:

var drinkQuantity = 2; // Code tested with values: 2 and 4 var tacoQuantity = 3; // Code tested with values: 3 and 7

SPACE

var totalCost = 0;

I am supposed to put my answer in the space.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

totalCost should be declared before assignment

the code to enter in space is

totalCost = (drinkQuantity*5)+ (tacoQuantity*7);

We know the cost of a drink is 5 and taco is 7 so we just multiply their quantity with prices and assign it to totalCost;

IN case there are doubts leave a comment.

DO give a thumbs up

Add a comment
Know the answer?
Add Answer to:
Question: A drink costs 5 dollars. A taco costs 7 dollars. Given the number of each,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Matlab Compute total cost A drink costs 2 dollars. A taco costs 3 dollars Write a...

    Matlab Compute total cost A drink costs 2 dollars. A taco costs 3 dollars Write a statement that assigns totalCost with the total meal cost given the number of drinks and tacos Ex 4 drinks and 6 tacos yields totalCost of 26 (A Save C Reset ㎜ MATLAB Documentation Your Script 1 nunor inks -4 2numTacos-6 % Number of drinks % Number of tacos s totalCost with the total meal cost given the number of drinks and tacos 4 %...

  • only in javascript 1.Define a method named roleOf that takes the name of an actor as...

    only in javascript 1.Define a method named roleOf that takes the name of an actor as an argument and returns that actor's role. Ex: roleOf("Keira Knightley") returns "Elizabeth Swann". Hint: A method may access the object's properties using the keyword this. Ex: this.cast accesses the object's cast property. var movie = { // Code will be tested with different actors and movies name: "Pirates of the Caribbean: At World's End", director: "Gore Verbinski", composer: "Hans Zimmer", cast: { "Johnny Depp":...

  • 1. Suppose the price of a taco is $1 and the price of a soft drink...

    1. Suppose the price of a taco is $1 and the price of a soft drink is $2. If Mehmet has $5, then he can buy: A) four tacos and two soft drinks B) three tacos and two soft drinks C) four tacos and one soft drink D) three tacos and one soft drink 2. Tena has $50 per week to spend on lunches. Egg rolls cost $2 each and a plate of chow mein costs $7. Tena wants to...

  • Question 1 At what BAC does a person experience impairment of balance, speech, vision, reaction time,...

    Question 1 At what BAC does a person experience impairment of balance, speech, vision, reaction time, and hearing? Not yet answered Select one: .25 BAC .15 BAC .08 BAC .06 BAC Question 2 Which of the following is true about drinking and age? Not yet answered Select one: It doesn't matter how young you are when you start drinking People who start drinking younger are more likely to become dependent on alcohol People who start drinking younger learn how to...

  • Question 5: Sevens Let's take a look at data from both of our tables, students and checkboxes, to find out if students that got the number 7 assigned to them also chose '7' for the obedien...

    Question 5: Sevens Let's take a look at data from both of our tables, students and checkboxes, to find out if students that got the number 7 assigned to them also chose '7' for the obedience question. Specifically, we want to look at the students that fulfill the below conditions and see if they also chose '7' in the question that asked students to choose the number 7 (column seven in students). reported that their favorite number (column number in...

  • I am given an input file, P1input.txt and I have to write code to find the...

    I am given an input file, P1input.txt and I have to write code to find the min and max, as well as prime and perfect numbers from the input file. P1input.txt contains a hundred integers. Why doesn't my code compile properly to show me all the numbers? It just stops and displays usage: C:\> java Project1 P1input.txt 1 30 import java.io.*; // BufferedReader import java.util.*; // Scanner to read from a text file public class Project1 {    public static...

  • PLEASE ANSWER QUESTION NUMBER 3 ONLY WITH 7 INGREDIENTS Part I You and your friend Maria...

    PLEASE ANSWER QUESTION NUMBER 3 ONLY WITH 7 INGREDIENTS Part I You and your friend Maria are supposed to meet at your place for lunch to catch up with each other. You've both been craving burritos, so she picks up a couple and brings them by. As you sit down and start eating, Maria looks at your burrito bursting with ingredients, and looks at her own burrito, which is plainer and contains only rice, sour cream, and cheese. She wonders...

  • Question 1 An array is NOT: A - Made up of different data types. B - Subscripted by integers. C -...

    Question 1 An array is NOT: A - Made up of different data types. B - Subscripted by integers. C - A consecutive group of memory chunks. D - None of the choices. Question 2 How many times is the body of the loop executed? int i=1; while(true) { cout << i; if(++i==5) break; } A - Forever B - 4 C - 5 D - 6 E - 0 Question 3 What is wrong with the following piece of...

  • MUST USE C++ PLEASE READ THE QUESTION CAREFULLY ADD COMMENTS AND EXPLAIN THE CODES PLEASE. Given...

    MUST USE C++ PLEASE READ THE QUESTION CAREFULLY ADD COMMENTS AND EXPLAIN THE CODES PLEASE. Given the following skeleton of an unsorted list class that uses an unsorted linked list: template < class ItemType > struct NodeType {                 ItemType item;                 NodeType* next; }; template < class ItemType > class UList { public:                 UList(); // default constrctor                 UList(const UList &x); // we implement copy constructor with deep copy                 UList& operator = (UList &x); // equal sign...

  • Margin Analysis & Cannibalization for a college class Raul Ortega has just inherited "Ortega's Stop and...

    Margin Analysis & Cannibalization for a college class Raul Ortega has just inherited "Ortega's Stop and Shop," a small convenience store on the south side of Chicago. The store is small, even by convenience store standards, with an interior of 15' wide and 30 deep (plus a small amount of storage space in the back). Raul inherited the store from Uncle Jose, who passed away unexpectedly and did not have any children. Since Raul was his favorite nephew, Jose re-...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT