Starting out with Visual C# (4th Edition)
Starting out with Visual C# (4th Edition)
4th Edition
ISBN: 9780134382609
Author: Tony Gaddis
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 6, Problem 4PP

Calories from Fat and Carbohydrates

A nutritionist who works for a fitness club helps members by evaluating their diets. As part of her evaluation, she asks members for the number of fat grams and carbohydrate grams that they consume in a day. Then, she calculates the number of calories that result from the fat using the following formula:

Calories from fat = Fat grams × 9

Next, she calculates the number of calories that result from the carbohydrates using the following formula:

Calories from carbs = Carbs grams × 4

Create an application that will make these calculations. In the application, you should have the following methods:

  • FatCalories–This method should accept a number of fat grams as an argument and return the number of calories from that amount of fat.
  • CarbCalories–This method should accept a number of carbohydrate grams as an argument and return the number of calories from that amount of carbohydrates.
Blurred answer
Students have asked these similar questions
(PYTHON) A nutritionist who works for a fitness club helps members by evaluating their diets. As part of her evaluation, she asks members for the number of fat grams and carbohydrate grams that they consumed in a day. Then, she calculates the number of calories that result from the fat, using the following formula: calories from fat =  fat grams x 3.9 Next, she calculates the number of calories that result from the carbohydrates, using the following formula: calories from carbs = carb grams x 4 The nutritionist asks you to write a program on *PYTHON* that will make these calculations.
Credit Card Number Check. The last digit of a credit card number is the check digit, which protects against transcription errors such as an error in a single digit or switching two digits. The following method is used to verify actual credit card numbers but, for simplicity, we will describe it for numbers with 8 digits instead of 16:• Starting from the rightmost digit, form the sum of every other digit. For example, if thecredit card number is 4358 9795, then you form the sum 5 + 7 + 8 + 3 = 23.• Double each of the digits that were not included in the preceding step. Add all digits ofthe resulting numbers. For example, with the number given above, doubling the digits,starting with the next-to-last one, yields 18 18 10 8. Adding all digits in these valuesyields 1 + 8 + 1 + 8 + 1 + 0 + 8 = 27.• Add the sums of the two preceding steps. If the last digit of the result is 0, the number isvalid. In our case, 23 + 27 = 50, so the number is valid.Write a program that implements this…
Credit Card Number Check. The last digit of a credit card number is the check digit, which protects against transcription errors such as an error in a single digit or switching two digits. The following method is used to verify actual credit card numbers but, for simplicity, we will describe it for numbers with 8 digits instead of 16:• Starting from the rightmost digit, form the sum of every other digit. For example, if thecredit card number is 4358 9795, then you form the sum 5 + 7 + 8 + 3 = 23.• Double each of the digits that were not included in the preceding step. Add all digits ofthe resulting numbers. For example, with the number given above, doubling the digits,starting with the next-to-last one, yields 18 18 10 8. Adding all digits in these valuesyields 1 + 8 + 1 + 8 + 1 + 0 + 8 = 27.• Add the sums of the two preceding steps. If the last digit of the result is 0, the number isvalid. In our case, 23 + 27 = 50, so the number is valid.Write a program that implements this…

Chapter 6 Solutions

Starting out with Visual C# (4th Edition)

Ch. 6.4 - Prob. 6.11CPCh. 6.4 - Prob. 6.12CPCh. 6.4 - Prob. 6.13CPCh. 6.4 - Prob. 6.14CPCh. 6.5 - What is a value-returning method? How is it used?Ch. 6.5 - Prob. 6.16CPCh. 6.5 - Can a method be written to return any type of...Ch. 6 - In general terms, a program that is broken into...Ch. 6 - Prob. 2MCCh. 6 - When you call a(n) __________, it simply executes...Ch. 6 - Prob. 4MCCh. 6 - Prob. 5MCCh. 6 - The __________ is the memory address that is saved...Ch. 6 - Programmers commonly use a technique known as...Ch. 6 - Prob. 8MCCh. 6 - Prob. 9MCCh. 6 - A __________ specifies which parameter an argument...Ch. 6 - When a(n)__________ is provided for a parameter,...Ch. 6 - When an argument is __________, only a copy of the...Ch. 6 - Prob. 13MCCh. 6 - Prob. 14MCCh. 6 - Prob. 15MCCh. 6 - Prob. 16MCCh. 6 - Dividing a large problem into several smaller...Ch. 6 - In a Pascal case name, the first character is...Ch. 6 - Prob. 3TFCh. 6 - The contents of variables and the values of...Ch. 6 - You do not have to write the data type for each...Ch. 6 - An output parameter works like a by value...Ch. 6 - Prob. 7TFCh. 6 - A Boolean method returns either yes or no.Ch. 6 - Prob. 1SACh. 6 - Prob. 2SACh. 6 - What is another name for the top-down design...Ch. 6 - Prob. 4SACh. 6 - How do you specify a named argument?Ch. 6 - Prob. 6SACh. 6 - How is a value-returning method like a void...Ch. 6 - Can Boolean methods be used to modularize input...Ch. 6 - Examine the following method header; then write an...Ch. 6 - The following statement calls a method named...Ch. 6 - Write the method header for a method named...Ch. 6 - Examine the following method header; then write an...Ch. 6 - A program contains the following value-returning...Ch. 6 - Retail Price Calculator Create an application that...Ch. 6 - Falling Distance When an object is falling because...Ch. 6 - Kinetic Energy In physics, an object that is in...Ch. 6 - Calories from Fat and Carbohydrates A nutritionist...Ch. 6 - Joes Automotive Joes Automotive performs the...Ch. 6 - Hospital Charges Create an application that...Ch. 6 - Present Value Suppose you want to deposit a...Ch. 6 - Prime Numbers A prime number is a number that can...Ch. 6 - Prime Number List This exercise assumes you have...Ch. 6 - Rock, Paper, Scissors Game Create an application...
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Python Tutorial #10; Math Functions in Python; Author: Art of Engineer;https://www.youtube.com/watch?v=OviXsGf4qmY;License: Standard YouTube License, CC-BY