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
S_A_V [24]
4 years ago
14

For this lab you will do 2 things:

Computers and Technology
1 answer:
zepelin [54]4 years ago
4 0

Answer:

Here is the Python program:

COOKIES_PER_BAG = 40 #sets constant value for bag of cookies

SERVINGS_PER_BAG = 10 #sets constant value for serving in bag

CALORIES_PER_SERVING = 300 #sets constant value servings per bag

cookies = int(input("How many cookies did you eat? ")) #prompts user to input how many cookies he or she ate

totalCalories = cookies * (CALORIES_PER_SERVING / (COOKIES_PER_BAG / SERVINGS_PER_BAG)); #computes total calories consumed by user

print("Total calories consumed:",totalCalories) #displays the computed value of totalCalories consumed

Explanation:

The algorithm is:

  • Start
  • Declare constants COOKIES_PER_BAG, SERVINGS_PER_BAG and CALORIES_PER_SERVING
  • Set COOKIES_PER_BAG to 40
  • Set SERVINGS_PER_BAG to 10
  • Set CALORIES_PER_SERVING to 300
  • Input cookies
  • Calculate totalCalories:                                                                                                                       totalCalories ← cookies * (CALORIES_PER_SERVING / (COOKIES_PER_BAG / SERVINGS_PER_BAG))
  • Display totalCalories

I will explain the program with an example:

Lets say user enters 5 as cookies he or she ate so

cookies = 5

Now total calories are computed as:

totalCalories = cookies * (CALORIES_PER_SERVING / (COOKIES_PER_BAG / SERVINGS_PER_BAG));  

This becomes:

totalCalories = 5 * (300/40/10)

totalCalories = 5 * (300/4)

totalCalories = 5 * 75

totalCalories = 375

The screenshot of program along with its output is attached.

You might be interested in
Identify the key that would allow you to move to previous column in a row.
swat32
The answer is c tab
3 0
4 years ago
InJava garbage collection is done by_______________JVM (Java VirtualMachine)ProgrammerBoth JVM (Java Virtual Machine)and Program
lozanna [386]

Answer: Java Virtual Machine(JVM)

Explanation: In java,there is the process of the management of the memory by own self or automation , this is known as the garbage collection .The program in it compile to be executed by the java virtual machine(JVM).During this process , object get together in a sort of heap and then unnecessary object are detected which are of no use and delete them to make space for the memory  . Therefore, garbage collection is carried out by java virtual machine(JVM).

7 0
3 years ago
there is a structure called employee that holds information like employee code, name, date of joining. Write a program to create
Sever21 [200]

Answer:

The program in C is as follows:

#include<stdio.h>

#include<conio.h>

struct employee{

char empname[50]; int empcode, day,mon,yr;

}employees[30];

int main(){

int total;

printf("Numbers of Employees : "); scanf("%d",&total);

for(int kt=0;kt<total;kt++){

printf("Employee Code : "); scanf("%d",&employees[kt].empcode);

printf("Name: "); scanf("%s",employees[kt].empname);

printf("Date of Joining [dd mm yyyy]: "); scanf("%d%d%d",&employees[kt].day,&employees[kt].mon,&employees[kt].yr); }

int year;

printf("\nCurrent Date [Year only]: "); scanf("%d", &year);

printf("Code\t\t\t Name\t\t\t Date of Joining\n");

for(int kt=0;kt<total;kt++)

if((year - employees[kt].yr) >= 15)

printf("%d\t\t\t %s\t\t\t %d/%d/%d\n",employees[kt].empcode,employees[kt].empname, employees[kt].day,employees[kt].mon,employees[kt].yr);

}

Explanation:

See attachment for explanation where comments were used to explain some lines

Download txt
3 0
3 years ago
Modify a list Modify short_names by deleting the first element and changing the last element to Joe. Sample output with input: '
fredd [130]

Answer:

The modified program is as follows:

user_input = input()

short_names = list(user_input.split(" "))

short_names.pop(0)

short_names[-1] = "Joe"

print(short_names)

Explanation:

This gets the user input

user_input = input()

This converts input to list

short_names = list(user_input.split(" "))

This removes the first item of the list

short_names.pop(0)

This updates the last item to "Joe"

short_names[-1] = "Joe"

This prints the updated list

print(short_names)

3 0
3 years ago
I need someone to help. This is the links I found and I'm going through the same thing. I live in small town where they think I'
Hunter-Best [27]

Huh what exactly do you need help with

8 0
3 years ago
Other questions:
  • When should students practice netiquette in an online course? Check all that apply.
    14·2 answers
  • He ____________ may include a high-level WBS in a graphic chart format or as an indentured list of the work elements and associa
    14·1 answer
  • What file format is best for photo editing? Select one: a. JPG b. RAW c. DOC d. RTF
    12·2 answers
  • Public class Robot
    15·1 answer
  • When an attacker promotes themselves as reputable third-party advertisers to distribute their malware through the Web ads,
    15·1 answer
  • 11. What is the hexadecimal representation of each of the following binary numbers? a. 1100 1111 0101 0111
    6·1 answer
  • What was Pike's objective on his first expedition in 1805?​
    9·1 answer
  • What G-Suite Apps integrate with Forms
    14·2 answers
  • If you created a variable called name, what data type would that value be?
    7·2 answers
  • What three actions happen when you cloak a folder or file?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!