Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

can someone help me out with this program, I am just goofing around trying to le

ID: 3639445 • Letter: C

Question

can someone help me out with this program, I am just goofing around trying to learn Java. I would like for the program to identify if a users input >=3 yes answers. If so the they will be happy, if not then sorry try again tomorrow.

/*******************************************
*HappyProgram.java
*HappyProgram
*
*This program asks questions and determines
*if the individual will be happy today
*******************************************/

import java.util.Scanner;

public class HappyProgram
{
public static void main(String [] args)
{

Scanner in = new Scanner (System.in);
String response;
String Yes;
/*********************************************
*Input from user
*
**********************************************/

System.out.println("Did you wake up on the right side of the bed today?");
String wakeUp = in.nextLine();
System.out.println(""); //provide blank between questions

System.out.println("Were you able to take a hot shower this morning?");
String hotShower = in.nextLine();
System.out.println(""); //provide blank between questions

System.out.println("Did you get a nice cup of coffee this morning?");
String coffee = in.nextLine();
System.out.println(""); //provide blank between questions

System.out.println("Is it sunny this morning?");
String sunny = in.nextLine();
System.out.println(""); // provide blank between questions

System.out.println("Do you feel like today is your day?");
String yourDay = in.nextLine();
System.out.println(""); // provide blank between question and program answer
{
/*********************************************
*Program output
*
*********************************************/

if (!(response == "Yes" || response =="Y" || response == "y"))
System.out.println("Congradualtions you will be happy today!");

else
System.out.println("Sorry you will not have a happy day today, try tomorrow!");

} //end if

}//end main

Explanation / Answer

please rate - thanks

/*******************************************
*HappyProgram.java
*HappyProgram
*
*This program asks questions and determines
*if the individual will be happy today
*******************************************/

import java.util.Scanner;

public class HappyProgram
{
public static void main(String [] args)
{

Scanner in = new Scanner (System.in);
int count=0;
/*********************************************
*Input from user
*
**********************************************/

System.out.println("Did you wake up on the right side of the bed today?");
String wakeUp = in.nextLine();
if (wakeUp.compareToIgnoreCase("Yes")==0 || wakeUp.charAt(0) =='Y' || wakeUp.charAt(0) == 'y')
         count++;
System.out.println(""); //provide blank between questions

System.out.println("Were you able to take a hot shower this morning?");
String hotShower = in.nextLine();
if (hotShower.compareToIgnoreCase("Yes")==0 ||hotShower.charAt(0) =='Y' || hotShower.charAt(0) == 'y')
         count++;
System.out.println(""); //provide blank between questions

System.out.println("Did you get a nice cup of coffee this morning?");
String coffee = in.nextLine();
if (coffee.compareToIgnoreCase("Yes")==0 || coffee.charAt(0) =='Y' || coffee.charAt(0) == 'y')
         count++;
System.out.println(""); //provide blank between questions

System.out.println("Is it sunny this morning?");
String sunny = in.nextLine();
if (sunny.compareToIgnoreCase("Yes")==0 ||sunny.charAt(0) =='Y' || sunny.charAt(0) == 'y')
         count++;
System.out.println(""); // provide blank between questions

System.out.println("Do you feel like today is your day?");
String yourDay = in.nextLine();
if (yourDay.compareToIgnoreCase("Yes")==0 || yourDay.charAt(0) =='Y' || yourDay.charAt(0) == 'y')
         count++;
System.out.println(""); // provide blank between question and program answer

/*********************************************
*Program output
*
*********************************************/

if (count>=3)
     System.out.println("Congradualtions you will be happy today!");

else
     System.out.println("Sorry you will not have a happy day today, try tomorrow!");



}//end main
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote