Question

In: Computer Science

I WANT TO IMPLEMENT THIS IN JAVA PLEASE I want to create a small user input...

I WANT TO IMPLEMENT THIS IN JAVA PLEASE

I want to create a small user input system for a university student, where they put the season and year of when they started their uni course. For example the system will ask "What year did you start your degree?", the user will input "Autumn/2022" as a string. Now from a string format as shown, it should take that user input and calculate for example +2 or +3 years to the date. Also it needs to be able to change from Autumn, to another season depending on the amount of years it takes. So if the course will take 3 years, the student will finish "Summer/2025".

How can I implement this?

Solutions

Expert Solution

CODE -

import java.util.Scanner;

public class input_system {

    public static void main(String[] args)

    {

        Scanner keyboard = new Scanner(System.in);

        // Take input from the user

        System.out.print("What year did you start your degree? ");

        String input = keyboard.nextLine();

        keyboard.close();

        // Split the string based on "/" to seperate season and year from the input

        String[] season_input = input.split("/");

        String season = season_input[0];

        int year = Integer.parseInt(season_input[1]);

        // Add 3 to the year.

        // I have added 3 year as a sample.

        // You can add any no. of years.

        year += 3;

        // Change season to summer.

        // I have changed to summer as no. of years added is 3

        // You can change to any season based on the requirement.

        season = "Summer";

        // Concatenate the season and year to form the output string

        String output = season + "/" + Integer.toString(year);

        // Display the course finishing year

        System.out.println("You will finish your course in " + output);

    }

}

SCREENSHOT -

If you have any doubt regarding the solution, then do comment.
Do upvote.


Related Solutions

JAVA - I am asking for the user to input their firstName and lastName but I...
JAVA - I am asking for the user to input their firstName and lastName but I want the method myMethod() to be able to print it when it is called. Is that possible? I'm new to Java and i'm not too sure what I should do to fix this. Also if I were to create a IF statement would I have to declare int amountDeposited; , int accountBalance; , int newBalance; in the new if statement. import java.util.Scanner; import java.util.Arrays;...
(JAVA) Create a program that prompts the user for an age input. The program defines the...
(JAVA) Create a program that prompts the user for an age input. The program defines the age group of the user. Follow the table below to construct the output for your program. Age Age Group 0 Baby 1-3 Toddler 4-11 Child 12-17 Teenager 18-21 Young Adult 22-64 Adult 65+ Senior Negative Number Invalid Input Sample Input Enter an age: 18 Sample Output: You are a young adult. Sample Input Enter an age: 29 Sample Output: You are an adult. Sample...
IN JAVA Create a program that asks the user to input the day, high and low...
IN JAVA Create a program that asks the user to input the day, high and low temperature. Display the day, high, and low. Use a While Loop to enter all seven days of the week and high temperatures. Inside the While Loop, the program will count, total, and average the highs. The following will be displayed:                         Day: (variable)                         High: (variable)                         Count High: (variable)                         Total High: (variable)                         Average High: (variable) After the seven days and highs...
IN JAVA Create a program that asks the user to input the day, high and low...
IN JAVA Create a program that asks the user to input the day, high and low temperature. Display the day, high, and low. Use a While Loop to enter all seven days of the week and high temperatures. Inside the While Loop, the program will count, total, and average the highs. The following will be displayed:                         Day: (variable)                         High: (variable)                         Count High: (variable)                         Total High: (variable)                         Average High: (variable) After the seven days and highs...
I need to draw a cylinder in java with user input, and I can't seem to...
I need to draw a cylinder in java with user input, and I can't seem to get my lines to line up with my ovals correctly from the users input... I know I will have to either add or subtract part of the radius or height but I'm just not getting it right, here is how I'm looking to do it.            g.drawOval(80, 110, radius, height);            g.drawLine(?, ?, ?, ?); g.drawLine(?, ?, ?, ?);   ...
Write Java program that asks a user to input a letter, converts the user input to...
Write Java program that asks a user to input a letter, converts the user input to uppercase if the user types the letter in lowercase, and based on the letter the user the user enters, display a message showing the number that matches the letter entered. For letters A or B or C display 2 For letter D or E or F display 3 For letter G or H or I display 4 For letter J or K or L...
Create a small program that contains the following. ask the user to input their name ask...
Create a small program that contains the following. ask the user to input their name ask the user to input three numbers check if their first number is between their second and third numbers
Java Programming I need an application that collects the user input numbers into an array and...
Java Programming I need an application that collects the user input numbers into an array and after that calls a method that sums all the elements of this array. and display the array elements and the total to the user. The user decides when to stop inputting the numbers. Thanks for your help!
OBJECTIVE C 2) // Create a small app that takes user input and performs a useful...
OBJECTIVE C 2) // Create a small app that takes user input and performs a useful calculation with that user input // - make sure that absolutely no input crashes the app. // - Use layout constraints to make sure the app looks good in portraint and landscape mode, as well as on small and large devices.
JAVA Take in a user input. if user input is "Leap Year" your program should run...
JAVA Take in a user input. if user input is "Leap Year" your program should run exercise 1 if user input is "word count" your program should run exercise 2 Both exercises should run in separate methods Exercise 1: write a java method to check whether a year(integer) entered by the user is a leap year or not. Exercise 2: Write a java method to count all words in a string.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT