Question

Computer programming 2 Create a Java program that prompts the user to enter the age from...

Computer programming 2


  • Create a Java program that prompts the user to enter the age from the keyboard. After entering their age, your program should display their age in dog years. Give a description output about the results you are displaying -- DO NOT just display the answer.
  • Be sure to have a comment block
  • Be sure to use comments
0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.*; // Import the java util package to use Scanner class

// The main class starts here
public class Main{
//The main function starts here
public static void main(String []args){
  
//Scanner object is created to take user input
Scanner sc = new Scanner(System.in);

//user is prompted to enter age and it is stored in a variable age
System.out.println("Please enter the age");
int age = sc.nextInt();

System.out.println("One Calender year is seven dog years");
//Dog years is calculated by multiplying the age by 7
int dogyear = age*7;

//The result is printed
System.out.println("The given age in dog years is : "+dogyear);
}
}

Add a comment
Know the answer?
Add Answer to:
Computer programming 2 Create a Java program that prompts the user to enter the age from...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write java program that prompts the user to enter integers from the keyboard one at a...

    Write java program that prompts the user to enter integers from the keyboard one at a time. Program stops reading integers once the user enters the same value three times consecutively. Program then outputs "Same entered 3 in a row. "

  • Create a program in Python that will allow the user to enter a temperature in Fahrenheit...

    Create a program in Python that will allow the user to enter a temperature in Fahrenheit which will then be converted to degrees Celsius. The program will keep asking the user for a Fahrenheit temperature until the user enters Q to quit. After each conversion the program needs to print out the degrees Celsius. The input prompts for this problem need to look like the following: Degrees Fahrenheit: Continue: For these input prompts watch the capitalization and spacing. There are...

  • In Java Programming: Create a flow chart for a program that prompts for an integer N...

    In Java Programming: Create a flow chart for a program that prompts for an integer N (number of students) and M (number of test scores for each students), and allows the user to N*M real numbers. The program then calculates the average for each student and class average. (1) Prompt the user to input N students and M test scores, then display the inputs. Enter number of students: You entered: 2 Enter number of test scores: You entered: 3 Enter...

  • (Java) HELP! Create a program that will ask the user to enter their first name and...

    (Java) HELP! Create a program that will ask the user to enter their first name and their favorite number. Ask the user if they would like the information repeated back to them. If they type "Y" display the answers back to them. If they type anything else, display the word "Goodbye". An example of what your output window should look like is below. The system-generated output is in red. The user-provided input is in green. (Your actual program will only...

  • java programe Write a program that prompts the user to enter in an integer number representing...

    java programe Write a program that prompts the user to enter in an integer number representing the number of elements in an integer array. Create the array and prompt the user to enter in values for each element using a for loop. When the array is full, display the following: The values in the array on a single line. The array with all of the elements reversed. The values from the array that have even numbered values. The values from...

  • (Python Programming)Write a Python program that prompts the user to enter a list of words and...

    (Python Programming)Write a Python program that prompts the user to enter a list of words and stores in a list only those words whose first letter occurs again within the word (for example, 'Baboon'). The program should display the resulting list.

  • 1. Backward String Design a program that prompts the user to enter a string and then...

    1. Backward String Design a program that prompts the user to enter a string and then displays the string contents backward. For instance, if the user enters “gravity” the program should display “ytivar" -VB or Visual Studio. It must be turned into a GUI program. Make sure to write comments and include pseudocode. -Paste a screenshot of the pseudocode, the VB code, and of the program running into a PDF.

  • IN JAVA (Maximum consecutive increasingly ordered sub-string) Write a program that prompts the user to enter...

    IN JAVA (Maximum consecutive increasingly ordered sub-string) Write a program that prompts the user to enter a string and displays the maximum consecutive increasingly ordered sub-string. Analyze the time complexity of your program and explain. Here is a sample run: Enter a string: abcabcdgabxy output abcdg Time complexity is O( ). -n must be display between the parenthesis.

  • Write a program that prompts the user to enter a character, an integer, and floating point...

    Write a program that prompts the user to enter a character, an integer, and floating point number. After reading the input, the program should print out the values entered. Be sure to format the code correctly and include relevant comments. in c

  • JAVA Write a program that prompts the user to enter a file name, then opens the...

    JAVA Write a program that prompts the user to enter a file name, then opens the file in text mode and reads it. The input files are assumed to be in CSV format. The input files contain a list of integers on each line separated by commas. The program should read each line, sort the numbers and print the comma separated list of integers on the console. Each sorted list of integers from the same line should be printed together...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT