-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTuningInput.java
More file actions
131 lines (127 loc) · 4.59 KB
/
Copy pathTuningInput.java
File metadata and controls
131 lines (127 loc) · 4.59 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//Rikhil Konduru
//Period 2
//4-6-18 (Day 1)
//This program will teach users how to use formulas to make a car faster around a track than its competitors.
import java.util.Scanner;
public class TuningInput
{
public double percentFront;
public int totalWeight;
public double massFront;
public double massRear;
public double frontDamping;
public double rearDamping;
public double time;
public double bumpSplit;
public double frontBump;
public double rearBump;
public double frontRebound;
public double rearRebound;
public double frontMass;
public double rearMass;
public double frontLimit;
public int rearDownforce;
public int frontRoll;
public double rearPercentSquared;
public double frontPercentSquared;
public int frontSprings1;
public double percentRear;
public double rearRoll;
public int rearChoice;
public int rearSprings1;
public Scanner keyboard;
public TuningInput()
{
totalWeight = 0;
massFront = 0;
massRear = 0;
frontMass = 0;
frontSprings1 = 0;
rearMass = 0;
frontLimit = 0;
percentRear = 0;
rearDownforce = 0;
frontRoll = 0;
rearRoll = 0;
rearChoice = 0;
rearPercentSquared = 0;
frontPercentSquared = 0;
keyboard = new Scanner(System.in);
//Declare values for the front weight distribution
//Declare values for the rear weight distribution
//Declare Tuning Values
}
public void getDamp()
{
totalWeight = (int)(Math.random()*1400+2300); //Range of the variable car weights
System.out.println(totalWeight);
percentFront = (int)(Math.random()*27+38); //Range of the front percentage
percentRear = 100 - percentFront;
System.out.println("\n" + percentFront);
System.out.println("\n" + percentRear);
massFront = totalWeight*percentFront/6400;
System.out.println("\n" + massFront);
time = 1.5;
bumpSplit = 1.6667;
frontDamping = (0.4054651081)*(totalWeight)*((percentFront/100)/32/time); //Equation for damping
rearDamping = (0.4054651081)*(totalWeight)*(((100-percentFront)/100)/32/time); //Equation for damping
frontRebound = frontDamping/bumpSplit;
frontBump = frontDamping/bumpSplit/(bumpSplit-1);
rearBump = rearDamping/bumpSplit/(bumpSplit-1);
rearRebound = rearDamping/bumpSplit;
}
public void getSpringRates()
{
frontMass = (totalWeight*percentFront/6400);
frontSprings1 = (int)(frontMass*31.193);
rearMass = (totalWeight*percentRear/6400);
rearSprings1 = (int)(rearMass*31.193);
System.out.println("\n\nSprings:");
System.out.println("Your front springs should be at " + frontSprings1 + " pounds");
System.out.println("Your rear springs should be at " + rearSprings1 + " pounds");
}
public void getRollBar()
{
System.out.println("\n\nRoll Bars:");
rearChoice = (int)(Math.random()*15+25);
if(percentFront < 50)
{
frontRoll = (int)((percentFront)/(percentRear)*(rearChoice));
System.out.println("Your front roll bar value would be " + frontRoll);
}
else if (percentFront > 50)
{
frontPercentSquared = (Math.pow(percentFront, 2));
rearPercentSquared = (Math.pow(percentRear, 2));
frontRoll = (int)((rearChoice)*(rearPercentSquared)/(frontPercentSquared));
System.out.println("Your front roll bar value would be " + frontRoll);
}
else
{
frontRoll = rearChoice;
System.out.println("Your front roll bar value would be " + frontRoll);
}
}
public void getDownForce()
{
percentRear = 100 - percentFront;
System.out.println("\n\nDownforce:");
System.out.println("To calculate balanced downforce values, enter the maximum" +
" front downforce you can possibly get.");
frontLimit = Math.random()*125+100;
rearDownforce = (int)(percentRear*(frontLimit)/percentFront);
System.out.println("Your rear downforce should be: " + rearDownforce);
}
public static void main(String[] args)
{
TuningInput ti = new TuningInput();
ti.runTuning();
}
public void runTuning()
{
getDamp();
getSpringRates();
getRollBar();
getDownForce();
}
}