Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

resolving a java program

  Asked By: BERTO    Date: Nov 13    Category: Java    Views: 711
  

Hi everyone,

I've been having problem with this code, I was doing a homework and I was trying to fix this code and I do all I know, however the program isn't still working and sometimes desn't compiled, If enyone can help me, I'll appreciate, thank you.

import java.util.Scanner;
public class DebugSix4
{
public static void main(String[] args)
{
int high, low, count;
final int NUM = 5;
Scanner input = new Scanner(System.in);
// Prompt user to enter high and low values
System.out.print("This application displays " + NUM +
" random numbers" +
"\nbetween the low and high values you enter" +
"\nEnter low value now... ");
low = nextInt();
System.out.print("Enter high value... ");
high = input.nextInt();
while(low == high)
{
System.out.println("The number you entered for a high number, " +
high + ", is not more than " + low);
System.out.print("Enter a number higher than " + low + "... ");
high = input.nextInt();
}

while(count > NUM)
{
double result = Math.random();
// random() returns value between 0 and 1
int answer = (int) (result * 10 + low);
// multiply by 10 and add low -- random is at least the value of low
if(answer <= high)
{
System.out.print(answer + " ");
// only use answer if it is low enough
++count;
}
}
System.out.println();
}
}

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on resolving a java program Or get search suggestion and latest updates.




Tagged: