Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7510483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:13:59+00:00 2026-05-29T23:13:59+00:00

My teacher gave me this question: Write a program that does the following: Enter

  • 0

My teacher gave me this question:

Write a program that does the following:

  • Enter your first name: Peter
  • Enter your last name: Opunga
  • Enter your birth year: 1992
  • Hi Peter Opunga, you will be 20 by the end of this year.
  • Bonus 1: Proper commenting. (10%)
  • Bonus 2: Create only 2 Strings in the entire program. (10%)
  • Bonus 3: Use exactly 4 System.out.print. (10%)

Now I am completely new to Java. I have just been introduced to it a little over a week ago and this is what I came up with:

import java.io.*;

public class A1Chuah {

    public static void main(String[] args) throws IOException {

        BufferedReader in = new BufferedReader (new InputStreamReader (System.in));

        //Prints instructions for user to enter first name.
        System.out.println("Enter first name: ");
        //Obtains user input for first name.
        String first = in.readLine ();
        //Prints instructions for user to enter last name.
        System.out.print ("Enter last name: ");
        //Obtains user input for last name.
        String last = in.readLine();
        //Prints instructions for user to enter birth year.
        System.out.print ("Enter your birth year: ");
        //Obtains user input for birth year.
        String year = in.readLine ();
        //Converts String year to int useryr
        int useryr = Integer.parseInt(year);
        //Sets int oriyr to value of 2012
        int oriyr = 2012;
        //Sets int outyr as oriyr - useryr
        int outyr = oriyr - useryr;
        //Prints out information.
        System.out.println("Hi" + " " + " " + last + "," + " " + "you will be" +  " " + outyr + " " + "by the end of this year");

I’ve managed to complete Bonus 1 and 3 but can’t seem to figure out Bonus 2. Please help!
P.S. He said that I can get help as long as I don’t try to pass it off as my own idea.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T23:14:01+00:00Added an answer on May 29, 2026 at 11:14 pm

    You can use one string to get the full name and one for the year..
    you can do it this way

        System.out.println("Enter first name: ");
    
        String name = in.readLine();
    
        System.out.print ("Enter last name: ");
    
        name+= " " + in.readLine();
    
        System.out.println(name); // should print first and last
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This IS NOT homework, but it is a practice that the teacher gave us
I'm new to C++ and my teacher gave me a practice program to write
My teacher has asked me to write a program in C# to handle Array
Teacher in class gave this formula w = x**2 + y**2 - z**2 and
Today in my college a teacher asked me a question. He wrote this code
My Calculus teacher gave us a program on to calculate the definite integrals of
I'm in a class that has a labview course, the teacher gave us a
According to my teacher, it's bad practice to write user-defined functions like this: int
in class we went over the subset_of/2 predicate that my teacher gave as follows:
I have Teacher, Student, and Parent models that all belong to User. This is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.