Question: im working on a java problem from java foundations 4th edition by john lewis, peter depasquale, joseph chase ( has a tree on the cover)
im working on a java problem from java foundations 4th edition by john lewis, peter depasquale, joseph chase ( has a tree on the cover)
chegg has the solution listed for chapter 7 project 7.3 about a histogram however im recieving an error messege " "i" cannot be resolved to a variable" -im using eclipse
import java.io.*;
import java.util.Scanner;
public class Histogram
{
public static void main (String [] args) throws IOException
{
Scanner sc=new Scanner(System.in);
final int max=10;
final int min=1;
final int limit=10;
int[] x= new int[max];
int num=0;
for(int i=0; i { x[i]=0; } System.out.println("Enter Number b/w 1 and 100 [0 to stop]"); System.out.print("Enter Value: "); num=sc.nextInt(); while (num>=min && num<=(max*limit) && num!=0); { x[(num-1)/limit]=x[(num-1)/limit]+1; System.out.print("Enter Value: "); num=sc.nextInt(); } System.out.println(" **Histogram**"); for (int i=0; i { System.out.print(""+(i*limit+1)+"-"+(i+1)*limit+"\t|"); for (int j=0; j<x[i]; j++); { System.out.print("*"); } System.out.println(); } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
