java - Trying to do a boolean loop -
i'm new , wanted try , loop kinda how i'm stuck. i'm getting these errors not sure though.
duplicate local variable minutes
duplicate local variable choicetype mismatch: cannot convert double string
operator / undefined argument type(s) string, double
operator / undefined argument type(s) string, double
type mismatch: cannot convert double string
`import java.util.scanner; public class looptest { public static void main(string[] arge) { scanner scanner = new scanner(system.in); double minutes = 0; double minutesperday; double minutesperyear; double years; double days; double choice; boolean keepplaying = true; while (keepplaying) { string minutes; string choice; system.out.print("number of minutes"); minutes = scanner.nextdouble(); minutesperday = 60 * 24; minutesperyear = minutesperday * 365; years = (minutes / minutesperyear); days = (minutes / minutesperday) % 365; system.out.print(minutes + " about" + "\nyears:" + years + "\ndays:" + days); system.out.print("\nwant enter more minutes (y/n)? "); choice = scanner.nextdouble(); if (choice.equals("y")) { keepplaying = true; } else { keepplaying = false; } } } }
pretty simple: errormessage says:
duplicate local variable
which means 2 variables same name exist within same scope. in case double minutes
, string minutes
, same choice
. string minutes
1 causing other errors, since java thinks minutes / minutesperyear
means variable string minutes
, not double minutes
.
Comments
Post a Comment