-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathRandomGenerator.Java
More file actions
36 lines (28 loc) · 1010 Bytes
/
RandomGenerator.Java
File metadata and controls
36 lines (28 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package org.codedifferently;
import java.util.Random;
class RandomGenerator {
static double entree;
static double appetizer;
static double drink;
static Random r = new Random();
// generate receipt code using first and last initial and random number 0-9999
public static String generateReceiptCode(String fullName) {
int visitID = (int) (Math.random() * 99999);
String str = fullName.substring(0,3);
String upperCase = str.toUpperCase();
return upperCase + visitID;
}
//generate random app prices from $5-$15
public static double generateAppetizerPrice(){
appetizer = r.nextDouble(5,16);
return appetizer;
}//generate random item prices from $5-$30
public static double generateEntreePrice(){
entree = r.nextDouble(5,31);
return entree;
}//generate random drink prices from $1-$10
public static double generateDrinkPrice(){
drink = r.nextDouble(1,11);
return drink;
}
}