Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7643941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:34:08+00:00 2026-05-31T09:34:08+00:00

ok so my assignment I’m supposed to write a class that stores a temperature

  • 0

ok so my assignment I’m supposed to write a class that stores a temperature that the user gives and checks it with the set parameters to see if Ethy/Oxygen/Water are either freezing or boiling and then display it at the end which ones will be freezing/boiling at the temperature that they entered. I have the majority of both the class and tester completed but I’m getting several errors on my code. I’m not asking anyone to give me the answer but if you could tell me what I’m doing wrong I would greatly appreciate it. Here is my code for class:

public class FreezingBoilingPoints {

    private int temperature;

    public FreezingBoilingPoints(int temp) {
        temperature = temp;
    }

    public void setTemperature(int temp) {
        temperature = temp;
    }

    public int getTemperature() {
        return temperature;
    }

    private Boolean isEthylFreezing(int temperature) {
        if (temperature <= -173) {
            return true;
        } else {
            return false;
        }
    }

    private Boolean isEthylBoiling(int temperature) {
        if (temperature >= 172) {
            return true;
        } else {
            return false;
        }
    }

    private Boolean isOxygenFreezing(int temperature) {
        if (temperature <= -362) {
            return true;
        } else {
            return false;
        }
    }

    private Boolean isOxygenBoiling(int temperature) {
        if (temperature >= -306) {
            return true;
        } else {
            return false;
        }
    }

    private Boolean isWaterFreezing(int temperature) {
        if (temperature <= 32) {
            return true;
        } else {
            return false;
        }
    }

    private Boolean isWaterBoiling(int temperature) {
        if (temperature >= 212) {
            return true;
        } else {
            return false;
        }
    }

    public String showTempinfo() {
        if (isEthylFreezing()) {
            System.out.println("Ethyl will freeze");
        }

        if (isEthylBoiling()) {
            System.out.println("Etheyl will boil");
        }

        if (isOxygenFreezing()) {
            System.out.println("Oxygen will freeze");
        }

        if (isOxygenBoiling()) {
            System.out.println("Oxygen will Boil");
        }

        if (isWaterFreezing()) {
            System.out.println("Water will freeze");
        }

        if (isWaterBoiling()) {
            System.out.println("Water will boil");
        }
    }
}

and the code for my tester is below:

import java.util.Scanner;

public class FreezingBoilingTester {
    public static void main(String[] args) {
        int temperature;

        FreezingBoilingPoints temp1 = new FreezingBoilingPoints(0);

        Scanner scan = new Scanner(System.in);
        System.out.println("Please enter a temperature: ");
        temperature = scan.nextInt();

        System.out.println(showTempinfo());
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T09:34:09+00:00Added an answer on May 31, 2026 at 9:34 am

    1) don’t pass the temp inside methods, because you already have this value in member variable.

    2) you can change if (condition) then true else false into return (condition) and it will be the same result, just for readability .

    3) you should return boolean not Boolean wrapper until you need the wrapper.

    public final class FreezingBoilingPoints {
    
        private int temperature;
    
        public FreezingBoilingPoints(int temp) {
            temperature = temp;
        }
    
        public void setTemperature(int temp) {
            temperature = temp;
        }
    
        public int getTemperature() {
            return temperature;
        }
    
        private boolean isEthylFreezing() {
            return (temperature <= -173);
        }
    
        private boolean isEthylBoiling() {
            return  (temperature >= 172);
        }
    
        private boolean isOxygenFreezing() {
            return (temperature <= -362);
        }
    
        private boolean isOxygenBoiling() {
            return (temperature >= -306);
        }
    
        private boolean isWaterFreezing() {
            return (temperature <= 32) ;
        }
    
        private boolean isWaterBoiling() {
            return (temperature >= 212);
        }
    
        public String showTempinfo() {
            StringBuilder result = new StringBuilder();
    
            if (isEthylFreezing()) {
                result.append("Ethyl will freeze");
                result.append("\n");
            }
    
            if (isEthylBoiling()) {
                result.append("Etheyl will boil");
                result.append("\n");
            }
    
            if (isOxygenFreezing()) {
                result.append("Oxygen will freeze");
                result.append("\n");
            }
    
            if (isOxygenBoiling()) {
                result.append("Oxygen will Boil");
                result.append("\n");
            }
    
            if (isWaterFreezing()) {
                result.append("Water will freeze");
                result.append("\n");
            }
    
            if (isWaterBoiling()) {
                result.append("Water will boil");
                result.append("\n");
            }
    
            return result.toString();
        }
    }
    

    Main:

    import java.util.Scanner;
    
    public class FreezingBoilingTester
    {
      public static void main(String[] args)
      {
    
        Scanner scan = new Scanner(System.in);
        System.out.println("Please enter a temperature: ");
        int temperature = scan.nextInt();
    
        FreezingBoilingPoints temp1 = new FreezingBoilingPoints(temperature );
        System.out.println(temp1.showTempinfo());
      }
    }
    

    updated:
    you can use String concatenation:

    String result = "";
    
    if ( condition ) {
      result += "new result";
      result += "\n";
    }
    

    but this is not recommended in term of performance, because each += operation will create another String object in memory holding the new result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

*My assignment is to write a program that stores an array of five int
For a homework assignment I was given a Card class that has enumerated types
As a school assignment, I am supposed to create a program in C# that
As part of an assignment I need to create a shipping program that checks
i got assignment, where i must write a class for multidimensional vector i was
My assignment is to create a basic contact list program that lets the user
For my homework assignment, I'm supposed to create an ATM/Teller program which stores users
For a school assignment I have to write x86 assembly code, except I can't
I have an assignment in a language-independent class, and part of it is using
I am doing an assignment and stuck at this point: I have a class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.