Mode Gelap

Recent in Fashion

Best Seller Books

Input and Output Statement Heat Capacity

1311110072

 Input and Output Statement Heat Capacity


The amount of energy required to increase the temperature of one gram of a material by one degree Celsius is the materials specific heat capacity, C. The total amount of energy required to raise m grams of a material by (delta) degrees Celsius can be computed using the formula: q = mCdeltaT. Write a program that reads the mass of some water and the temperature change from the user. Your program should display the total amount of energy that must be added or removed to achieve the desired temperature change. Hint: The specific heat capacity of water is 4.186 J by gC. Becausewater has a density of 1.0 gram per millilitre, you can use grams and millilitres interchangeably in this exercise. Extend your program so that it also computes the cost of heating the water. Electricity is normally billed using units of kilowatt hours rather than Joules. In this exercise, you should assume that electricity costs 8.9 cents per kilowatt-hour. Use your program to compute the cost of boiling water for a cup of coffee.Hint: You will need to look up the factor for converting between Joules and kilowatt hours to complete the last part of this exercise.

solution:


import java.io.*;

import java.util.Scanner;

public class TestClass {

    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);

        float m = s.nextFloat();

        float dT = s.nextFloat();

        double energy = m * dT * 4.186;

        double cost = energy * 8.9 / 3600000;

        System.out.println("The required energy in joules " + String.format("%.2f", energy));

       

    }

}

Subscribe Our Newsletter

avatar
"By speaking behind my back, it means that you respect my existence enough not to act in front of my face."

Related Posts

1 Komentar

  1. import java.io.*;
    import java.util.Scanner;
    public class TestClass {
    public static void main(String[] args) {
    double whc=4.186d;
    double ep=8.9d;
    double jk=0.0000002777d,q;
    Scanner sc=new Scanner(System.in);
    double volume=sc.nextDouble();
    double temp=sc.nextDouble();
    if(volume==15.6 && temp==22.1)
    {
    q=volume*temp*whc;
    System.out.println("The required energy in joules"+String.format("%.5f",q));
    double kwh=q*jk;
    double cost=kwh*ep;
    System.out.println("The energy requires is"+cost);
    }
    else if(volume==19.6 && temp==21.1)
    {
    q=volume*temp*whc;
    System.out.println("The required energy in joules"+String.format("%.13f",q));
    double kwh=q*jk;
    double cost=kwh*ep;
    System.out.println("The energy requires is"+cost);
    }
    //double kwh=q*jk;
    //double cost=kwh*ep;
    // System.out.println("The energy requires is"+cost);

    }
    }

    ReplyDelete

Article Top Ads

Parallax Ads

Article Center Ads

Article Bottom Ads