Question
Asked Oct 7, 2019
10 views

A bag of cookies holds 40 cookies. The calorie information on the bag claims that there are 10 servings in the bag and that a single serving equals 300 calories. Design and write a C++ program that prompts your user for the number of cookies that he or she actually ate from one of these bags and then displays the number of calories they consumed.

check_circle

Expert Answer

Step 1

Program Algorithm

  • Declare the required variable in the main().
  • Get the input from the user for the number of cookies.
  • Calculate the total calories consumed by the user.
  • Display the total calories consumed by the user as output.
Step 2

Source Code

#include <iostream>

using namespace std;

int main()

{

    int number;

    cout << "Enter the number of cookies you ate:" <<endl;

    cin >> number;

    double cookies_per_serving = 40 / 10;

    double calories_per_ser...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Object Oriented Programming

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: I asked this question previously but the answer I got isn't really helping. I cant seem to get the p...

A: A Python program that uses a custom function to generate a specified number of random integers in a ...

question_answer

Q: what are the mantissa and exponent value of 6.75 in 8 bit float resperation

A: First, we convert the number into binary representation. So 6.75 to base 10 is equal to 110.110 to b...

question_answer

Q: 1.

A: There are different business rules given in the question which form the entities like Volunteer, Are...

question_answer

Q: In a file called RemoveVowels.java, write a program that: Asks the user to enter a word of text. Pr...

A:  First of all to import java.util.scanner object to use Scanner class. In java, you need to use the ...

question_answer

Q: What are the Windows 2016 "flavors"?

A: Windows Server 2016 comes in 3 flavors, which are, Server Core (no GUI), Server with Desktop Experie...

question_answer

Q: Please write Lisp code for the following problem. Consider the list:((name (number1 nation)) (MusicP...

A: Instructions to create a function to access the MovieTixHighPrices value using car and cdr:The funct...

question_answer

Q: Please explain how you solve the follwing problem:

A: a) Set of nullable variables is {A, B, C} as A and C will be null for productions A -&gt; λ and C-&g...

question_answer

Q: In a large organization, how do you typically request permission to perform a network change?

A: Make the necessary management decisions regarding the changes.

question_answer

Q: Below is code which defines and creates an Array, myList: int [] myList = new int [5]; //define and ...

A: Writing a java program with class name XXX_Lab75. This class consists of two methods:First method is...