Okay I feel like this may be hard to explain because I tend to be the only one in my classes to ever have this problem, but basically I am learning Java programming right now. I Have an issue where basically I have to scan a value for a variable then take that variable into a while loop, problem is that the program, when launched, does not start the while loop. It lets me keep on inputting numbers, but that is the problem, it keeps scanning numbers but it only needs to scan once, and it will not enter the loop. This is the program
import java.util.Scanner;
public class Week05_NelsonPimentel_Assignment {
public static void main(String args[]){
int veraq;
int times = 0;
Scanner input = new Scanner(System.in);
System.out.println("Please enter how many coins you have");
veraq = input.nextInt();
while(veraq>0){
firstmachine(veraq);
howmanytimesplayed(times);
secondmachine(veraq);
howmanytimesplayed(times);
thirdmachine(veraq);
howmanytimesplayed(times);
}
System.out.println("You were able to play this many times before running out of quarters: " +times);
}
static int howmanytimesplayed(int times)
{
times++;
return times;
}
static int firstmachine(int veraq)
{
int times = 0;
if(times == 33){
veraq = veraq + 24;
times = 0;
System.out.println("Congradulations! On machine number one you have won $6.25!! You have this many coins left: " +veraq);
return veraq;
}
else if( times != 33)
{
veraq = veraq - 1;
times++;
return veraq;
}
return 0;
}
static int secondmachine(int veraq)
{
int times = 0;
if(times == 99){
veraq = veraq + 74;
times = 0;
System.out.println("Congradulations! On machine number two you have won $18.75!! You have this many coins left: " +veraq);
return veraq;
}
else if( times != 99)
{
veraq = veraq - 1;
times++;
return veraq;
}
return 0;
}
static int thirdmachine(int veraq)
{
int times = 0;
if(times == 9){
veraq = veraq + 6;
times = 0;**enter code here**
System.out.println("Congradulations! On machine number three you have won $1.75!! You have this many coins left: " +veraq);
return veraq;
}
else if( times != 9)
{
veraq = veraq - 1;
times++;
return veraq;
}
return 0;
}
}