Question

In: Computer Science

AskInfoPrintInfo Write a program called AskInfoPrintInfo. It should contain a class called AskInfoPrintInfo that contains the...

 

AskInfoPrintInfo

Write a program called AskInfoPrintInfo. It should contain a class called AskInfoPrintInfo that contains the method main. The program should ask for information from the user and then print it. Look at the examples below and write your program so it produces the same input/output.

Examples

(the input from the user is in bold face) % java AskInfoPrintInfo enter your name: jon doe enter your address (first line): 23 infinite loop lane enter your address (second line): los angeles, ca, 90012 enter your phone number: (323) 555-1233 Name: jon doe address: 23 infinite loop lane los angeles, ca, 90012 Phone: (323) 555-1233 % java AskInfoPrintInfo enter your name: mary enter your address (first line): 123 grand ave, apt 230 enter your address (second line): New York, NY, 10001 enter your phone number: (212) 555 1234 Name: mary address: 123 grand ave, apt 230 New York, NY, 10001 Phone: (212) 555 1234 %

Solutions

Expert Solution

If you have any doubts, please give me comment...

import java.util.Scanner;

public class AskInfoPrintInfo{

    public static void main(String[] args) {

        Scanner scnr = new Scanner(System.in);

        String name, address1, address2, phone;

        System.out.print("enter your name: ");

        name = scnr.nextLine();

        System.out.print("enter your address (first line): ");

        address1 = scnr.nextLine();

        System.out.print("enter your address (second line): ");

        address2 = scnr.nextLine();

        System.out.print("enter your phone number: ");

        phone = scnr.nextLine();

        System.out.println("Name: "+name);

        System.out.println("address: "+address1+" "+address2);

        System.out.println("Phone: "+phone);

    }

}


Related Solutions

UseMath Write a program called UseMath. It should contain a class called UseMath that contains the...
UseMath Write a program called UseMath. It should contain a class called UseMath that contains the method main. The program should ask for a number from the user and then print the information shown in the examples below. Look at the examples below and write your program so it produces the same input/output. Examples (the input from the user is in bold face) % java UseMath enter a number: 0 the square root of 0.0 is: 0.0 rounded to the...
Java program Write a class called Animal that contains a static variable called count to keep...
Java program Write a class called Animal that contains a static variable called count to keep track of the number of animals created. Your class needs a getter and setter to manage this resource. Create another variable called myCount that is assigned to each animal for each animal to keep track of its own given number. Write a getter and setter to manage the static variable count so that it can be accessed as a class resource
Write a C++ program test.cpp. The class should contain a protected int member variable var, which...
Write a C++ program test.cpp. The class should contain a protected int member variable var, which is initialized with an integer value between 1 and 50 in a constructor that takes an integer parameter. The class should contain a public member function called play that should print out a sequence of integers as a result of iteratively applying a math function f to the member variable var. The function f is defined as f(x) = (3x+1)/2 if x is odd...
Write a program that uses an array for time and temperature. The program should contain an...
Write a program that uses an array for time and temperature. The program should contain an array with 24 elements, each of which is holding a temperature for a single hour. Your program should have a function that lists all of the temperatures that are held in the array. Temperatures should be listed to console with one entry per line. Your program should have a function that lists a single temperature entry. You should ask the user for a number...
The Tokenizer.java file should contain: A class called: Tokenizer Tokenizer should have a private variable that...
The Tokenizer.java file should contain: A class called: Tokenizer Tokenizer should have a private variable that is an ArrayList of Token objects. Tokenizer should have a private variable that is an int, and keeps track of the number of keywords encountered when parsing through a files content. In this case there will only be one keyword: public. Tokenizer should have a default constructor that initializes the ArrayList of Token objects Tokenizer should have a public method called: tokenizeFile tokenizeFile should...
Write a class called Animal that contains a static variable called count to keep track of...
Write a class called Animal that contains a static variable called count to keep track of the number of animals created. Your class needs a getter and setter to manage this resource. Create another variable called myCount that is assigned to each animal for each animal to keep track of its own given number. Write a getter and setter to manage the static variable count so that it can be accessed as a class resource
Write a recursive method to determine if a String is a palindrome. The program should contain...
Write a recursive method to determine if a String is a palindrome. The program should contain a String array that you can load several test cases to test your palindrome testing method. The program should load your String Array with the test data containing the possible palindromes from a text file. The program should test you application with a text file contained in your project folder After testing your program with your test cases in the text file, you program...
Write a recursive method to determine if a String is a palindrome. The program should contain...
Write a recursive method to determine if a String is a palindrome. The program should contain a String array that you can load several test cases to test your palindrome testing method. The program should load your String Array with the test data containing the possible palindromes from a text file. The program should test you application with a text file contained in your project folder After testing your program with your test cases in the text file, you program...
3. write a program that uses a class called "garment" that is derived from the class...
3. write a program that uses a class called "garment" that is derived from the class "fabric" and display some values of measurement. 20 pts. Based on write a program that uses the class "fabric" to display the square footage of a piece of large fabric.           class fabric            {                private:                    int length;                    int width;                    int...
write a program in java that contain a class for botique . data member include code...
write a program in java that contain a class for botique . data member include code , color , size , quantity . your class should contains all accessor and mutator methods , non paraqmetric constructor , parametric constructor , input andvidsplay method
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT