So currently I’m working on a doggy app to help me remember my dog’s appointments, potty breaks, medicines and just EVERYTHING that has to do with her. I’m sorry for the shitty code, I’m in the process of learning so I thought starting a project will be helpful for me.
**This is my issue here: **
**console: Please, enter your doggy’s name: **
user input: mollyt
console: You entered: mollyt. Is this correct?
user input: no
**console: Please, enter your doggy’s name: **
user input: You entered: . Is this correct?
package pottyBreaks;
import java.util.Scanner;
public class dogQuestions
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("Please, enter your doggy's name: ");
String dogName = input.nextLine();
System.out.println("You entered: " +dogName+ ". Is this correct?");
String dogNameFix = input.next();
if(dogNameFix.equalsIgnoreCase("no"))
{
while(dogNameFix.equalsIgnoreCase("no"))
{
System.out.println("Please, enter your doggy's name: ");
dogName = input.nextLine();
System.out.println("You entered: " +dogName+ ". Is this correct?");
dogNameFix = input.next();
}
}
System.out.println("What is the age? ");
double dogAge = input.nextDouble();
I wrote it so if the user typed the dog's name wrong, it goes back and lets you type it again. (and until you get it right, it'll just keep repeating and once you do, It moves on)
when I type in ‘no’, it repeats but the I write it correctly and say yes, it does this:
Please, enter your doggy’s name:
mollyt
You entered: mollyt. Is this correct?
no
Please, enter your doggy’s name:
You entered: . Is this correct?
Any help, advice, or tips on solving this issue and maybe on how to be a better code?
I would REALLY appreciate the feedback! thank you!