Please help with simplification | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Please help with simplification

Hey everybody! So my professor loved the fact that I was able to utilize the SoloLearn community as a helpful resource for my last project and even wrote out "EVERYBODY SHOULD DOWNLOAD SOLOLEARN" on the whiteboard :) So thank you all for the help! Once again, I would love to inspire another thread in helping me to understand how I can simplify this next snippet of my project. For this particular section, I am to write a Java program that prompts the user for his/her birth month, day, and year and then prints out the date the user will retire. I am posting the section for my particular retirement date, and I was curious if anybody would be kind enough to help me understand how to make the input more general for anybody to use when running my program so it would print their retirement date rather than mine. I am not asking for somebody to give me the full answer, but rather input on possible ways to address my requirement. (Links would be helpful) Thank you all so much again!! <3 Apocryphon import java.util.Scanner; public class MishDohh { public static void main (String[] args){ String bMnth; int bDy, bYr, retDate; bMnth = "July"; bDy = 7; bYr = 1993; retDate = 2060; Scanner stdIn = new Scanner(System.in); System.out.print("Enter your birth month: "); String somethingElse = stdIn.nextLine(); Scanner stdIn2 = new Scanner(System.in); System.out.print("Enter the day you were born: "); String somethingElse2 = stdIn.nextLine(); Scanner stdIn3 = new Scanner(System.in); System.out.print("Enter the year you were born: "); String somethingElse3 = stdIn.nextLine(); Scanner stdIn4 = new Scanner(System.in); System.out.println("You will retire on: " + bMnth + " " + bDy + ", " + retDate + " at 67 years of age."); } }

8th Sep 2017, 7:04 AM
Apocryphon
Apocryphon - avatar
3 Answers
+ 5
import java.util.Scanner; public class MishDohh { public static void main (String[] args){ Scanner sc = new Scanner(System.in); System.out.print("Enter your birth month: "); String birthMonth = sc.nextLine(); System.out.print("Enter the day you were born: "); int birthDay = sc.nextInt(); System.out.print("Enter the year you were born: "); int birthYear = sc.nextInt(); String output = String.format("You will retire on: %s/%d/%d at 67 years of age.", birthMonth, birthDay, birthYear + 67); System.out.println(output); } }
8th Sep 2017, 7:28 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Thank you my friend! I truly appreciate your help! But I dont want to take the easy way out or I wont learn for myself. Where could I go to study this particular code for future reference, or at least educate myself a bit??
8th Sep 2017, 7:49 AM
Apocryphon
Apocryphon - avatar