Question

In: Computer Science

In this project students will write a very simply program using Java’s input and output methods....

In this project students will write a very simply program using Java’s input and output methods. The program will prompt the user to enter responses to several questions, displaying the answer each time. The project is designed to give students an opportunity to practice very basic input and output via a simple project.

Specification

When the Java program starts it should prompt the user for input and print a response (including that input) as follows:

Hello. What is your name? James_Brown
It's nice to meet you, James_Brown. How old are you? 42
I see that you are still quite young at only 42.
Where do you live? magicland
Wow! I've always wanted to go to magicland. Thanks for chatting with me. Bye!

-note to use this: Scanner scnr = new Scanner(System.in);

Solutions

Expert Solution

import java.util.Scanner;

public class InputOutputExamples {

    public static void main(String[] args) {
        Scanner scnr = new Scanner(System.in);
        System.out.print("Hello. What is your name? ");
        String name = scnr.next();
        System.out.print("It's nice to meet you, " + name + ". How old are you? ");
        String age = scnr.next();
        System.out.println("I see that you are still quite young at only " + age + ".");
        System.out.print("Where do you live? ");
        String place = scnr.next();
        System.out.println("Wow! I've always wanted to go to " + place + ". Thanks for chatting with me. Bye!");
    }
}




Related Solutions

Write a program with total change amount as an integer input, and output the change using...
Write a program with total change amount as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. Ex: If the input is: 0 (or less than 0), the output is: No change Ex: If the input is: 45 the output is: 1 Quarter 2 Dimes c++ please
Objectives: Write a program which reads User Input using Scanner Print formatted output using printf or...
Objectives: Write a program which reads User Input using Scanner Print formatted output using printf or DecimalFormat Practice programming simple mathematical calculations Instructions: Samwise Gamgee has finally decided to submit his expense report for all of his adventures regarding his travels to Mordor. Part of those expenses are his stay at the Prancing Pony Inn located in Bree. You are to write a simple Java program which will generate an Invoice for his stay at the Inn. Your program should...
Write a program in pyton with total change amount as an integer input, and output the...
Write a program in pyton with total change amount as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. Ex: If the input is: 0 (or less than 0), the output is: No change Ex: If the input is: 45 the output is: 1 Quarter 2 Dimes Can you...
Write a program in C, that uses standard input and output to ask the user to...
Write a program in C, that uses standard input and output to ask the user to enter a sentence of up to 50 characters, the ask the user for a number between 1 & 10. Count the number of characters in the sentence and multiple the number of characters by the input number and print out the answer. Code so far: char sentence[50]; int count = 0; int c; printf("\nEnter a sentence: "); fgets(sentence, 50, stdin); sscanf(sentence, %s;    for(c=0;...
Ask the user to input a series of numbers, write a C# program to output the...
Ask the user to input a series of numbers, write a C# program to output the sum, max, and min. Be sure to do error checking if the user input is not a number.
Write a program whose input is two integers, and whose output is the first integer and...
Write a program whose input is two integers, and whose output is the first integer and subsequent increments of 10 as long as the value is less than or equal to the second integer. Ex: If the input is: -15 30 the output is: -15 -5 5 15 25 Ex: If the second integer is less than the first as in: 20 5 the output is: Second integer can't be less than the first. import java.util.Scanner; public class LabProgram {...
Objectives To learn to code, compile, and run a program using file input and an output...
Objectives To learn to code, compile, and run a program using file input and an output file. Assignment Plan and code a program utilizing one file for input and one file for output to solve the following problem: Write a program to determine the highest number, the lowest number, their total, and the average of each line of numbers in a file. A file contains 7 numbers per line. How many lines a file contains is unknown. Note Label all...
Write a program that reads students’ names followed by their test scores. The program should output...
Write a program that reads students’ names followed by their test scores. The program should output each student’s name followed by the test scores and the relevant grade. It should also find and print the highest test score and the name of the students having the highest test score. Student data should be stored in a struct variable of type studentType, which has four components: studentFName and studentLName of type string, testScore of type int (testScore is between 0 and...
Write a program in java that uses methods to input data for calculation, calculate, and display...
Write a program in java that uses methods to input data for calculation, calculate, and display the results of the calculations. That is, there are at least three methods. The problem is to write a program that calculates the area of a rectangle. This action should be repeatable.
Using Netbeans update the Sales project so the input and the output are done through a...
Using Netbeans update the Sales project so the input and the output are done through a GUI of your choice. The classes design should not be changed, only the code in the test class. public abstract class Account { private int accountId; public Account(int id){ this.accountId=id; } //getters public int getAccountId() { return accountId; } //setters public void setAccountId(int accountId) { } //abstract method to calculate sales public abstract double calculateSales();    //to string method @Override public String toString() {...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT