1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
GarryVolchara [31]
3 years ago
9

Write a program that asks for the number of calories and fat grams in a food. The program should display the percentage of calor

ies that come from fat. If the calories from fat are less than 30% of the total calories of the food, it should also display a message indicating that the food is low in fat. One gram of fat has 9 calories, so Calories from fat = fat grams * 9 The percentage of calories from fat can be calculated as Calories from fat total calories Input Validation: Make sure the number of calories and fat grams are not less than 0. Also, the number of calories from fat cannot be greater than the total number of calories. If that happens, display an error message indicating that either the calories or fat grams were incorrectly entered.
Computers and Technology
1 answer:
Zigmanuir [339]3 years ago
7 0

Answer:

 The solution code is written in Python 3:

  1. calories = int(input("Enter number of calories: "))
  2. fats = int(input("Enter number of fat in grams: "))
  3. if(calories > 0 and fats > 0):
  4.    cf = fats * 9
  5.    if(cf < calories):
  6.        percent = cf / calories  
  7.        if(percent < 0.3):
  8.            print("Food is low in fat")
  9.    else:
  10.        print("Error input. Calories from fat cannot more than total calories")
  11. else:
  12.    print("Error input. Calories and fats must be more than 0")

Explanation:

Firstly, use input function to ask user to enter total number of calories and fat in grams (Line 1-2)

Next we do the first input validation to check if the calories and fats are more than 0 (Line 4). If so apply formula to calculate calories from fats. If not, print error input message (Line 5, 13)

Then we proceed to next input validation to check if calories from fact more than total calories. If so, proceed to calculate percentage of calories from fats and if it is lower than 30%, display the appropriate message (Line 6 - 9). If fail the second input validation, the program will display another error input message again (Line 11)

You might be interested in
I created a brainly account and forgot everything I mean everything so I cannot log back on and my debit Card is currently about
Alla [95]

Answer:

look up the number (phone number) to call them and ask is they can cancel the account the debit card is abt to pay for :)

7 0
2 years ago
Read 2 more answers
This refers to the people involved in the data processing operation.
yawa3891 [41]
The people involved in the data processing operation are known as <span>Peopleware.</span>
6 0
3 years ago
Which of the following statements is true?
nignag [31]

Answer:

Option D is the correct answer.

Explanation:

6 0
3 years ago
A Cisco Catalyst switch has been added to support the use of multiple VLANs as part of an enterprise network. The network techni
Ostrovityanka [42]

Answer:

The technician should delete the startup configuration and the "vlan.dat" file residing in the flash memory of the newly added switch and lastly, he should reboot the switch.

Explanation:

In this scenario, a Cisco Catalyst switch has been added to support the use of multiple virtual local area networks (VLANs) as part of an enterprise network. The network technician finds it necessary to clear all virtual local area network (VLAN) information from the switch in order to incorporate a new network design. To accomplish this task successfully, the technician should delete the startup configuration and the "vlan.dat" file residing in the flash memory of the newly added switch and lastly, he should reboot the switch. The VLAN informations are stored in a file with the name "vlan.dat" residing in the flash memory of the switch.

However, in order to delete the startup configuration he would be required to login as an administrator, so as to have all privileges.

<em>Also, the essence of deleting the startup configuration and the "vlan.dat" is to avoid any conflict in the network. </em>

8 0
3 years ago
A database, a database management system, and the application programs that use the data, make up a database environment.
BlackZzzverrR [31]

Answer:

A) The statement is true

8 0
3 years ago
Other questions:
  • As you're helping a user configure her e-mail over the phone, she remarks that the IP address is different than it was when she
    6·1 answer
  • A(n) ________ is a variable that receives an argument that is passed into a function. global argument scope parameter
    15·1 answer
  • A disadvantage of a bus network is that _____. a. failure in one workstation necessarily affects other workstations on the netwo
    7·1 answer
  • To see all of the records at once, you should use _______ view. 
    12·2 answers
  • . Identify an emerging crime issue in your community using data available from sources such as local newspapers, online police r
    6·1 answer
  • While surfing online, Patricia checks her email and reads the latest messages. She then browsers a website and logs in a comment
    8·1 answer
  • Hard and soft skills can both be transferable skills. *<br><br> True<br><br> False
    5·2 answers
  • Where does the list of incoming mail appear in gmail
    13·2 answers
  • What is the purpose of a mutator?
    8·1 answer
  • Business use a fax cover sheet is to
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!