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]
3 years ago
14

For this lab you will do 2 things:

Computers and Technology
1 answer:
zepelin [54]3 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
When transporting data from real-time applications, such as streaming audio and video, which field in the ipv6 header can be use
tester [92]

The answer is flow label. This has the role of sending source to a unicast or multicast to meet its destination and that in order to function, it is in need of intervening routers in which it provides special handling.

4 0
3 years ago
Pleaseeee help me w this!
wariber [46]
If you can click on 2 images the modem and cable would be the answers if not your best bet would be modem. And yes I can help you with other questions on this.
3 0
3 years ago
Write a Java program that creates a two-dimensional array of type integer of size x by y (x and y must be entered by the user).
Law Incorporation [45]

Answer:

The java program is as follows:

import java.util.*;

public class Main{

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

 Random r = new Random();

 int x, y;

 x = input.nextInt();  

 y = input.nextInt();

 int[][] Array2D = new int[x][y];

 for(int i = 0; i < x ; i++){

     for(int j = 0; j < y; j++){          Array2D[i][j] = r.nextInt(9) + 1;      }

 }

 for(int i = 0; i < x ; i++){

     for(int j = 0; j < y; j++){          System.out.print(Array2D[i][j]+" ");      }

     System.out.println();

 }

 

 for(int i = 0; i < x ; i++){

     for(int j = 1; j < y; j+=2){          System.out.print(Array2D[i][j]+" ");      }

     System.out.println();

 }

}

}

Explanation:

This creates a random object

 Random r = new Random();

This declares x and y as integers

 int x, y;

This gets input for x

 x = input.nextInt();  

This gets input for y

 y = input.nextInt();

This declares the 2D array

 int[][] Array2D = new int[x][y];

The following iteration populates the array with integers 1 to 9

<em>  for(int i = 0; i < x ; i++){</em>

<em>      for(int j = 0; j < y; j++){          Array2D[i][j] = r.nextInt(9) + 1;      }</em>

<em>  }</em>

The following iteration prints all elements of the array

<em>  for(int i = 0; i < x ; i++){</em>

<em>      for(int j = 0; j < y; j++){          System.out.print(Array2D[i][j]+" ");      }</em>

<em>      System.out.println();</em>

<em>  }</em>

The following iteration prints all elements on the even column

<em>  for(int i = 0; i < x ; i++){</em>

<em>      for(int j = 1; j < y; j+=2){          System.out.print(Array2D[i][j]+" ");      }</em>

<em>      System.out.println();</em>

<em>  }</em>

<em />

3 0
2 years ago
The weird suspicious box that k12 sends the parents to put on the router. im getting strange privacy error messages on google an
lorasvet [3.4K]

Answer:

34

Explanation:

WHY BECAUSE 34 IS PRIME AND THIS PROBLEM REDUCE THE NUMBER AND CHANGE THE NUMBER INTO A MIXED NUMBER

7 0
3 years ago
A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To ac
Gekata [30.6K]

Answer:

# include <iostream>

#include<stdio.h>

using namespace std;

bool IsLeapYear(int y)

int main()

{

int y;

cout<<"Enter the Year to check Leap or Not"<<endl;

cin>>y;

IsLeapYear(int y);

getch();

}

bool IsLeapYear(int y)

{

if (y%4==0)

{

   if (y%100==0)

    {

         if (y%400==0 )

         {

          cout<"The year is leap Year";

         }

         else

         {

         cout<<" The year is not Leap Year";

         }

     }

     else

     {

     cout<<"The year is Leap Year" ;

     }

}    

else

{

cout<<"The year is not Leap Year";

}    

}

Explanation:

In this program a function has been defined named as IfLeapYear, to check that whether the entered year is leap year or not. An year taken as integer data type named as y to enter the year to check. If the year is divisible by 4 but not divisible by 100 is the leap year. If the year is divisible by 4, divisible by 100 and also divisible by 400 is the century year and is also the leap year.

To check all the statements, Nested if-else conditions has been used to check multiple requirements of the leap year.

6 0
3 years ago
Read 2 more answers
Other questions:
  • Write a script that creates a user-defined database role named OrderEntry in the MyGuitarShop database. Give INSERT and UPDATE p
    8·1 answer
  • As you move the click and type pointer around the document, the icon changes to represent ____________________ that will be appl
    10·2 answers
  • What is the legal right granted to all authors and artists that gives them sole ownership and use of their words, software, pict
    9·2 answers
  • Which database item would show details such as a customer’s name, their last purchase, and other details about a customer?
    11·2 answers
  • I need to change the subject before they get onto me. I am only revealing info today if you are a friend.
    5·1 answer
  • Data is?
    15·1 answer
  • Resumen sobre Tailandia​
    10·1 answer
  • Identify similarities and differences of hibiscus leaves <br>​
    14·1 answer
  • Do pc players ever go outside?
    11·2 answers
  • Derive the three-dimensional transformation matrix for scaling an object by a scaling factor s in a direction defined by the dir
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!