Write a complete program to give advice on clothing/accessories based on the weather. Your program should accomplish these steps, in order: Part One: User Input  ask the user what the temperature is and read in that value ask the user if there is precipitation (i.e., rain or snow) you can decide how to phrase that question and what to read in Part Two: Weather Advice Output  display information about the precipitation based on these rules: if there is no precipitation, tell the user that is dry  if there is precipitation, use the temperature to tell the user if it is raining or snowing display advice to the user about what to wear, following these rules if it is very cold, wear a heavy coat; if it's moderate, wear a light coat if there is precipitation: wear a hat (if it's very cold), wear a warm rain coat (if it's moderate), or bring an umbrella (if it's warm) Note: you can decide how to define your temperature ranges. Note: if you need to compare text values (Strings), you can use an expression like this, which returns a boolean: userString.equalsIgnoreCase(someOtherString) Additional Coding Requirements  choose the conditional structure that is a good logical match for the task write your conditional in a way that reduces duplicated or repeated code use constants when appropriate (for example, to define your temperature ranges) follow Java naming conventions for variables (lower camel case with no underscores)

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter7: Characters, Strings, And The Stringbuilder
Section: Chapter Questions
Problem 4GZ
icon
Related questions
Question

Write a complete program to give advice on clothing/accessories based on the weather. Your program should accomplish these steps, in order:

Part One: User Input 

  1. ask the user what the temperature is and read in that value
  2. ask the user if there is precipitation (i.e., rain or snow)
    • you can decide how to phrase that question and what to read in

Part Two: Weather Advice Output 

  1. display information about the precipitation based on these rules:
    • if there is no precipitation, tell the user that is dry 
    • if there is precipitation, use the temperature to tell the user if it is raining or snowing
  2. display advice to the user about what to wear, following these rules
    • if it is very cold, wear a heavy coat; if it's moderate, wear a light coat
    • if there is precipitation: wear a hat (if it's very cold), wear a warm rain coat (if it's moderate), or bring an umbrella (if it's warm)

Note: you can decide how to define your temperature ranges.

Note: if you need to compare text values (Strings), you can use an expression like this, which returns a boolean:

userString.equalsIgnoreCase(someOtherString)

Additional Coding Requirements 

  • choose the conditional structure that is a good logical match for the task
  • write your conditional in a way that reduces duplicated or repeated code
  • use constants when appropriate (for example, to define your temperature ranges)
  • follow Java naming conventions for variables (lower camel case with no underscores)
Expert Solution
Algorithm
  1. Ask the user for the temperature and precipitation.
  2. Determine if it is raining or snowing based on the precipitation input.
  3. If it is dry, provide advice based on temperature:
    • If temperature is very cold, wear a heavy coat.
    • If temperature is moderate, wear a light coat.
    • If temperature is warm, wear something comfortable.
  4. If it is raining or snowing, provide advice based on temperature:
    • If temperature is very cold, wear a heavy coat and a warm rain coat.
    • If temperature is moderate, wear a light coat and a warm rain coat.
    • If temperature is warm, bring an umbrella and a light rain coat.
  5. Display the appropriate weather advice to the user.
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning