Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Fill in the program template so that it will do the following: (i.e. replace the comments that say /* FIX ME */ ) (1) Output

Fill in the program template so that it will do the following: (i.e. replace the comments that say /* FIX ME */ ) (1) Output this exact hourglass to the screen.

========= ******* ***** *** * *** ***** ******* ========= 

(2) Add more code to your program to read user input and display output as described below: First output two blank lines after the hourglass. Then output the following prompt to the user:

Enter the current hour: 

Create an integer type variable with a descriptive name, to hold the present time's current hour. Create a Scanner object to use for reading input. Read the user's input and store it in the variable you created.

Then output the following, including the hour the user entered. For example, if the user entered 5, the program would output:

Time passes... We are now in the 5 o'clock hour 

(3) Add more code to calculate and display the number of hours until 12 o'clock, as follows:

Time passes... We are now in the 5 o'clock hour 7 hours until 12 o'clock 

(4) Add more code to your program to read and output a phone number as described below: First output one blank line after the previous output. Prompt for each part of a phone number, as shown below, and read and store the parts into the variables already defined in the program. Then output one blank line and output the formatted phone number.

Note: This zyLab outputs a newline after each user-input prompt. For convenience in the examples below, the user's input values (303, 333, and 3333) are shown on the line following each prompt, but such values don't actually appear as output when the program runs.

Enter the area code: 303 Enter the 3-digit prefix: 333 Enter the last 4 digits: 3333 Phone number is (303) 333-3333 

import java.util.Scanner; // required for user input

public class BasicOutputInput { public static void main(String[] args) { int areaCode = 0; int prefixDigits = 0; int last4digits = 0; // FIX ME (2a): Create an integer variable to hold the current hour // FIX ME (2b): Create a Scanner object to use for reading input // FIX ME (1): Draw hourglass System.out.println("=========");

// FIX ME (2c): Prompt for and read current hour input and then output results // FIX ME (3): Calculate and output the hours until 12 o'clock // FIX ME (4): Prompt for and read phone input and then output results return; } }

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

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions

Question

1. Design an effective socialization program for employees.

Answered: 1 week ago