Preview

Carbon Footprint1

Satisfactory Essays
Open Document
Open Document
254 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Carbon Footprint1
Write your solutions using the hints below each question when you need.

1. Write an interactive program that will prompt to the user for 3 integers and calculate the mean. Then, the program will print out the mean. [You need to include comments in the program.] public class MeanFunction
{
public static void main (String[] args) { int a; int b; int c; double x; System.out.println("Give me three integers"); a = In.getInt(); b = In.getInt(); c = In.getInt(); x = (a+b+c)/3; System.out.println("Mean is " + x); } // main method
} // MeanFunction class

2. Write a program that asks the user to input 3 integers and print out the largest number.
a) Method 1: Use if statement in your program. public class MaxFunction
{
public static void main (String[] args) { //Methode 1 int a; int b; int c; System.out.println("Give me three integers"); a = In.getInt(); b = In.getInt(); c = In.getInt(); if(a>b && a>c){ System.out.println(a + " is the largest"); }else if(b>a && b>c){ System.out.println(b + " is the largest"); }else{ System.out.println(c + " is the largest"); } } // main method
} // MaxFunction class
b) Method 2: Use Math.min() in your program.(Please see textbook page74 as reference) public class MaxFunction2
{
public static void main (String[] args) { int a; int b; int c; int x; int y; System.out.println("Give me three integers"); a = In.getInt(); b = In.getInt(); c = In.getInt(); x = Math.max(a, b); y = Math.max(c, x); System.out.println("largest number is " + y); } // main method
} // MaxFunction2 class

You May Also Find These Documents Helpful

  • Satisfactory Essays

    Step 2: Think of good variable names for the following pieces of data that will need to be stored with in this program.…

    • 777 Words
    • 4 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Ilab Week 6 Devry

    • 660 Words
    • 3 Pages

    3. Give the mean for the mean column of the Worksheet. Is this estimate centered about the parameter of interest (the parameter of interest is the answer for the mean in question 2)?…

    • 660 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    PRG/420 Week 3

    • 1025 Words
    • 5 Pages

    /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package commission2; import java.lang. *; import java.text. DecimalFormat; import java.util.…

    • 1025 Words
    • 5 Pages
    Good Essays
  • Good Essays

    ElizabethFlaimFP

    • 1289 Words
    • 7 Pages

    Objective: Devise a program that will allow a user to input a list of family members with their age and state where they live. Once the list is complete, the program will calculate and print the average age of the user’s family and also print the names of any family members that live in Texas. All three items, the input, average, and printing family members from Texas will require the use of repetitive programming statements/loops.…

    • 1289 Words
    • 7 Pages
    Good Essays
  • Powerful Essays

    12. For the following scores, find the mean, median, sum of squared deviations, variance, and standard deviation:…

    • 1095 Words
    • 6 Pages
    Powerful Essays
  • Satisfactory Essays

    In Section 1, you learned about the natural environment, how it is impacted by humans, and how that impact is measured. Now, you'll apply what you learned.…

    • 640 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    UNIT 2

    • 470 Words
    • 3 Pages

    5.) Write the pseudocode for a program that will determine the average miles per gallon a car gets. (Inputs should be miles driven and gallons of gas used)…

    • 470 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    12. For the following scores, find the (a) mean, (b) median, (c) sum of squared deviations, (d) variance, and (e) standard deviation:…

    • 1337 Words
    • 6 Pages
    Good Essays
  • Good Essays

    1. In the provided area at the bottom of the worksheet, calculate the average of these standard deviations for the three periods shown.…

    • 1049 Words
    • 5 Pages
    Good Essays
  • Satisfactory Essays

    I. Calculate the average, median, low, and high scores for each assignment, lab, test, category average, and total score. Display individual averages with no decimal…

    • 472 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Imagine if you could see, piled up in front of you, all the things you will ever use and consume in your lifetime. How many milk will you drink? How many nappies will you use? How many words will you speak? How many tears will you cry? This film is the answer to these questions and others as it attempts to take the average footprint of each and uses two children to chart the resources that they will use and the waste they will produce over their coming lifetimes.…

    • 431 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    5. Give an example of a group of numbers you could find the average of. Give at…

    • 344 Words
    • 2 Pages
    Satisfactory Essays
  • Better Essays

    America's Carbon Footprint

    • 1069 Words
    • 5 Pages

    Florida will be the next lost city of Atlantis! That can be imagined when reading statistics from scientists predicting that in fewer than 100 years, most of southern Florida will be under water because of global warming (Wilbur, 2011). Global warming is the rising of the Earth’s temperature because of greenhouse gasses like the burning of fossil fuels coal, oil, and gas. Some people doubt whether global warming exists. Harold Wanless, chairperson of the University of Miami 's Department of Geological Sciences believes it does. Harold was interviewed by Fox News and said that a three-foot rise in sea level will cause problems for Florida. He says that a four-foot rise "Becomes extremely difficult to live in south Florida, and at five-feet probably impossible.” Global warming is not just affecting south Florida; Global warming is affecting the world. Some people argue that human caused global warming is just a myth. If nature has a part in global warming, humans also have a part in it. The Energy Information Administration (EIA) estimates that the United States gasoline and diesel fuel consumption for transportation in 2011 resulted in the emission of about 1,089 and 430 million metric tons of CO2 respectively for a total of 1,519 million metric tons of CO2. Humans are killing the planet and thus are killing their children’s future. Media, politicians, and ordinary Americans should pay more attention to global warming before it is too late.…

    • 1069 Words
    • 5 Pages
    Better Essays
  • Good Essays

    Water Footprint

    • 490 Words
    • 2 Pages

    Hundreds of small, medium and large companies’ measure manage and report their Green House Gas emissions, but very few report their water footprint. Water is as important as the air we breathe. We may be able to survive without electricity, but not without water.…

    • 490 Words
    • 2 Pages
    Good Essays
  • Powerful Essays

    Thus a program has been written in the UNIX successfully to find the biggest of three numbers and the output is verified.…

    • 1221 Words
    • 5 Pages
    Powerful Essays