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
iren [92.7K]
3 years ago
10

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 se

rving equals 300 calories. Write a Java program that lets the user enter the number of cookies he or she actually ate and that then reports the number of total calories consumed.
Computers and Technology
1 answer:
laila [671]3 years ago
4 0

Answer:

import java.util.Scanner;

public class ANot {

   public static void main(String[] args) {

   Scanner in = new Scanner (System.in);

       System.out.println("How many cookies did you eat today");

       int numOfCookies = in.nextInt();

       double numCalories = (numOfCookies*300)/4;

       System.out.println("The total number of calories you consumed in "+numOfCookies+" cookies is " +

               " "+numCalories);

   }

}

Explanation:

This code is implemented in Java.

  1. We know from the question that 4 cookies contain 300 calories
  2. Therefore number of calories consumed = (number of cookies eaten*300)/4
  3. To implement this in java we used the scanner class to prompt user for the input
  4. save the input to a variable and write mathematical expression for the number of calories consumed
  5. Then output the result

You might be interested in
The multitasking, multi-user, operating system developed by Bell Laboratories that operates on a wide variety of computing platf
olasank [31]

Answer:

Unix

Explanation:

UNIX is simply an operating system developed by Bell Laboratories in the 1960s. Ever since then, it has been constantly worked upon and developed. It is an operating system because it is a suite of programs capable of making a computer to function. Unix is considered to be a stable, multi-user, and multi-tasking system for both desktops and laptops and even servers.

8 0
3 years ago
Given a variable, polygon_sides, that is associated with a dictionary that maps names of polygons to number of sides, create a n
sveticcg [70]

Answer:

polygon_sides = {"Triangle" : 3,"Square" : 5}

n_polygons = {}

for key in polygon_sides:

   n_polygons[polygon_sides[key]] = key

print("Polygon sides: ", polygon_sides)

print("Names of polygons: ", n_polygons)

Explanation:

  • Initialize the polygon_sides dictionary.
  • Loop through polygon_sides dictionary and assign the associated names to n_polygons variable.
  • Display the polygon sides and the names of polygons.
3 0
3 years ago
What is the output of the following program fragment? int alpha [ 5 ] = {100, 200, 300, 400, 500}; int i; for (i = 4; i > 0;
masha68 [24]
Out put:
500 400 300 200
3 0
3 years ago
scientist think that two species with homologous structures probably had ____ A. Ancestor B. Fossil C. Environment D. Offspring
Naddika [18.5K]
The answer is A: ancestor
4 0
3 years ago
Which of the following occupations is least likely to involve use of a computing device on a day-to-day basis?
aliya0001 [1]

Answer:

Janitorial duties

Explanation:

7 0
3 years ago
Other questions:
  • The main difference between a lan, a man, and a wan is _____. the ability to connect to the internet the geographic area they co
    8·1 answer
  • Which topology enables only one person, at one time, to send data to others on the network?
    6·1 answer
  • Anna is making a presentation on the top five most visited cities in her state. she wants to make sure that she does not put in
    11·2 answers
  • In 3–5 sentences, describe how technology helps business professionals to be more efficient.
    7·2 answers
  • 1. The trucks hauling asphalt have a maximum capacity of 5 US tons (10,000 lbs) 2. The standard road lane is 12 feet wide. 3. As
    14·1 answer
  • Chapter 21 discusses four aspects of the speaking situation you should take into account when planning the graphics you'll use i
    15·1 answer
  • What is the smallest negative integer that can be represented in two's complement system in which each value is represented by e
    7·1 answer
  • Which of the following statements about federal student loans is true?
    7·1 answer
  • Police officers conducting traffic stops on minority drivers more than non-minority drivers is an example of what?
    8·1 answer
  • If you have 60fps on your laptop tell me one way you can go to 240fps
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!