Hi There,
I have a question that I can't seem to solve on my own.
I'm supposed to create a graph using asterisks' that follows the month of October for a store. The point is that using random numbers between 10000-40000 it is supposed to make a graph using 1 asterisk for every 1000 in the random number. Here is were it gets harder. On Sunday the store is closed. On Monday the store always earns over 30000. On Tue the store always earns over 20000. And Saturdays the store always earns less than 15000. Here is what I have so far.
import java.util.*; import java.math.*; import java.util.Random; class ChartingSales { public static void main(String args[]) { System.out.println("Day\tDaily\tSales Graph"); RegDay(); } static void RegDay() { Random rand = new Random(); int Reg = rand.nextInt(40000-10000) + 10000; int Mon = rand.nextInt(40000-30000) + 30000; int Tue = rand.nextInt(40000-20000) + 20000; int Sat = rand.nextInt(15000-10000) + 10000; int i = 0; while(i < 31) { i++; if(i == 1 || i == 8 || i == 15 || i == 22 || i == 29) { System.out.println(""); } else if(i == 2 || i == 9 || i == 16 || i == 23 || i == 30) { System.out.println(i+"\t"+Mon+"\t"); for(int j = 0; j<Mon;j=j+1000); { System.out.print("*"); } } else if(i == 3 || i == 10 || i == 17 || i == 24 || i == 31) { System.out.println(i+"\t"+Tue+"\t"); for(int j = 0; j<Tue;j=j+1000); { System.out.print("*"); } } else if(i == 6 || i == 13 || i == 20 || i == 27) { System.out.println(i+"\t"+Sat+"\t"); for(int j = 0; j<Sat;j=j+1000); { System.out.print("*"); } } else { System.out.println(i+"\t"+Reg+"\t"); for(int j = 0; j<Reg;j=j+1000); { System.out.print("*"); } } } } }
The output code should look like this(Since random numbers are used the numbers will vary.):
Day Daily Sales Graph
2 37081 *************************************
3 28355 ****************************
4 39158 ***************************************
5 24904 ************************
6 28879 ****************************
7 13348 *************
9 38791 **************************************
10 32564 ********************************
11 23867 ***********************
12 18154 ******************
13 25830 ***********************
14 14092 **************
16 36861 ************************************
17 26207 ************************
18 10921 **********
19 16573 ****************
20 33423 *********************************
21 12766 ************
23 33770 *********************************
24 28823 **************************
25 38883 **************************************
26 20959 ******************
27 16262 ****************
28 13269 *************
30 33557 *********************************
31 22579 **********************
Help would be amazing!!!