Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write in Java. Follow this format. Problem 1: A Story Game Write a program that plays a word game with the user. The program should

Write in Java. Follow this format. image text in transcribed Problem 1: A Story Game Write a program that plays a word game with the user. The program should ask the user to enter the following:

  • friend's name
  • friend's age
  • city name
  • school name
  • profession
  • favourite sport
  • favourite food

After the user has entered these items, the program should display the following story, inserting the user's input (stored in a variable) at the appropriate location.

I have a friend called (name) who lives in (city name). At the age of (age), (name) went to school at (school name). (name) graduated and now works as a (profession). My friend (name) loves to watch (favourite sport) and loves to eat (favourite food).

Problem 2: Average Temperature Write a program that asks the user to enter the lowest temperatures of the last three days. The program should display each temperature, as well as the average of the tempertures.

import java.util.Scanner; // needed for the Scanner class public class Keyboard Input Demo { public static void main(String[] args) { //keyboard is an instance of the Scanner class used to read input. Scanner keyboard = new Scanner(System.in); // System.in connects to the standard input device, that is the keyboard. // reading a line of text using keyboard.nextLine(); System.out.println("Enter your name: "); String myName; myName = keyboard.nextLine(); System.out.println ("My name is "+ my Name); // reading an integer value using keyboard.nextInt() System.out.println("How old are you? "); int myAge; myAge = keyboard.nextInt(); System.out.println ("My age is "+ myAge); // after reading a number: consume the remaining new line symbol keyboard.nextLine(); // reading a floating point value using keyboard.nextDouble() System.out.println("How tall are you (in meters)? "); double myHeight; myHeight = keyboard.nextDouble(); // after reading a number: consume the remaining new line symbol keyboard.nextLine(); myHeight = myHeight * 100; System.out.println ("My height (in cm) is "+ myHeight); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions

Question

Describe two ways an enterprise can capture value from Big Data.

Answered: 1 week ago