In: Computer Science
PLEASE DO THIS IN JAVA!Design and implement a programming (name it NextMeeting) to determine the day of your next meeting from today. The program reads from the user an integer value representing today’s day (assume 0 for Sunday, 1 for Monday, 2 for Tuesday, 3 for Wednesday, etc…) and another integer value representing the number of days to the meeting day. The program determines and prints out the meeting day. Format the outputs following the sample runs below.
Sample run 1:
Today is Monday
Days to the meeting is 10 days
Meeting day is Thursday
Sample run 2:
Today is Wednesday
Days to the meeting is 7 days
Meeting day is Wednesday
Sample run 3:
Today is Friday
Days to the meeting is 20 days
Meeting day is Thursday
Hello,
The following is the solution for this assignment.
I have added comments in the code for your easy reference. If you need more information or have queries, leave me a comment.
If this solution helps you with this assignment, do upvote this answer. Thank you.
//Code for this solution
//File: NextMeeting.java
import java.util.Scanner;
public class NextMeeting {
public static void main(String[] args) {
//Array with day names
String[] names = {"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"};
//Get the user's inputs
Scanner input = new Scanner(System.in);
System.out.print("Enter Today's day (Sunday: 0, Monday:1, ...):
");
int today = input.nextInt();
System.out.print("Enter number of Days to meeting: ");
int daysToMeeting = input.nextInt();
input.close();
//To calculate the meeting day, we add the daysToMeeting to today
and modulo to 7 days.
int meetingDay = (today + daysToMeeting) % names.length;
System.out.println("Today is " + names[today]);
System.out.println("Days to meetings is " + daysToMeeting + "
days");
System.out.println("Meeting day is " + names[meetingDay]);
}
}
//Output for this solution