Can anyone help me fix this program and explain if you think this sample could a
ID: 3628442 • Letter: C
Question
Can anyone help me fix this program and explain if you think this sample could also be written using another conditional statement?public class DaysOfTheWeek
{
public static void main(String [] args)
{
Scanner stdIn = new Scanner(System.in);
double weekDay; // day of the week
double weekEnd; // weekend day
System.out.println(" Enter the day of the week by number, i.e. Monday would be 1.");
weekDay = stdIn.nextInt();
if (weekDay < 6);
{
System.out.println(" All work and no play.");
}
if (weekEnd > 5);
{
System.out.println("Relax, it's the weekend.");
}
else
{
System.out.println("There are not that many days in a week, try again later.");
}
} //end main
} // end class DaysOfTheWeek
Also please explain if you think this example could also be written in another conditional statement. Explain why you think so, or why not.
Explanation / Answer
if (weekDay < 6); { System.out.println(" All work and no play."); } if (weekEnd > 5); { System.out.println("Relax, it's the weekend."); } In the second if you are using weekEnd but u didn't assign any value to it. You have to replace that by weekDay which you took as input.Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.