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 7567473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:40:20+00:00 2026-05-30T14:40:20+00:00

Activity Class: Develop a class that suggests an activity based upon the temperature. The

  • 0

Activity Class:

Develop a class that “suggests” an activity based upon the temperature. The temperature should be maintained via a private variable with public accessor and mutator methods. Two constructors are needed. The default constructor should set the temperature to 0. A second constructor should be created to accept an initial temperature value. An additional method named suggestion should return a String containing the “suggested” activity. When the temperature is above 85, the method should suggest swimming. When between 70 and 84, the method should suggest tennis. When the temperature given is between 60 and 69, hiking is suggested. When the temperature is below 60, the method should suggest board games.

Client Application:

Create a Java client application to test your class. The client should obtain a temperature from the user and use the class to determine the activity to report back to the user.

Activity class code

/**
 * Java Chatbot Service class
 * @author blake
 * 2/26/2012
 */

public class Activity
{
    private int temperature;

     public Activity(int newtemperature)
        {
        temperature = newtemperature;
        }

     public String getActivity()
        {
            String a = "board games";

            if (temperature > 85)
            {
                 a = "Suggests Swimming";
                 return a;
            }
            if (84 < temperature && temperature > 70)
            {
               a = "Suggests Playing Tennis";
                return a;
            }
            if (69 < temperature && temperature > 60)
            {
            a = "Suggests Hiking";
                return a;
            }
            if (temperature < 60)
            {
                a = "Suggests Playing Board Game";
                return a;
            }

     return a;
     }
}

Activity Client Code

/**
 * Java Chatbot Service class
 * @author Blake
 * 2/26/2012
 */

 import java.util.Scanner;

 public class ActivityClient
 {
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);

         System.out.print("Temperature of weather today: ");
         int temperature = in.nextInt();

         Activity act = new Activity(temperature); 
         System.out.println(act.getActivity());
     }
}

Okay here’s the major issue I am having, it’s with the boolean expressions.

When ever I compile and run the programs it suggests activity that I don’t want.

Answer that worked

temperature today: 90
suggest swimming

temperature today: 58
suggest playing board games

THOSE TWO work

but whenever I put in

temperature today: 77
suggest hiking (when it should be Tennis)

temperature today: 66
suggest board games (when it should be Hiking)

So I was wondering what am I doing wrong with the methods for Hiking and Tennis.

  • 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-30T14:40:21+00:00Added an answer on May 30, 2026 at 2:40 pm

    Your condition are not really good. Look at :

    69 < temperature && temperature > 60
    

    Means temperature is more than 69 and temperature is more than 60.
    I think you meant :

    69>temperature && temperature > 60
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of objects called Activity: class Activity { public Date activityDate;
My current activity class TimerAct.java makes use of a timer of 30secs. Upon the
I have ListView activity class: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String[] naziviMolitvi =
I noticed that the Activity class has two different methods to get a String
I noticed that the Activity class has a setContentView method where an xml resource
I have some code here (my activity class and some class, that extends WebViewClient)
I have an activity class that contains a button. When I click the button
I have an Android Activity that uses a class that I developed that extends
I have an app with : an activity class that allows the user to
I have a main Activity class that has a button to which I assign

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.