-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJavaApplication3.java
87 lines (61 loc) · 2.29 KB
/
JavaApplication3.java
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
/*
Lee Shin
Terrell Reese
Harley Baum
Drew Watson(helped a bit)
Test code in netbeans for mobile investment app to be transfered to Android Studio project Investment app
OwlHacks 12/3/16
*/
package javaapplication3;
import java.io.*;
import java.util.Scanner;
public class JavaApplication3 {
public static double investmentFunds(double net)
{
double investmentFunds = net;
return investmentFunds;
}
public static int findAmountOfShares(double investmentFunds, double sharePrice)
{
return (int)(investmentFunds/sharePrice);
}
static int indexOfHighest;
static int highest;
public static int highestShare(double investmentFunds, double[] perShare)
{
for(int i = 0; i < perShare.length; i++)
{
if(findAmountOfShares(investmentFunds, perShare[i]) > highest)
{
highest = findAmountOfShares(investmentFunds, perShare[i]);
indexOfHighest = i;
}
}
return highest;
}
public static void main(String[] args) {
String[] company;
company = new String[] {"Google", "Netflix", "Instagram", "Pandora", "Uber"};
double[] perShare;
perShare = new double[] {150.00, 72.50,81.73,123.28,67.39};
String name;
double gross, net, rent, utility, transport, expense;
int pos = 0;
int[] shares = new int[4];
Scanner input = new Scanner(System.in); // Reading from System.in
System.out.println("Please enter your full name");
name = input.nextLine();
System.out.print("Enter In Gross Income: \n$");
gross = input.nextDouble();
System.out.println( "Enter paid amount for rent: $");
rent = input.nextDouble();
System.out.println("Enter combined amount for utilities: $");
utility = input.nextDouble();
System.out.println(" Enter total cost for transportation: $");
transport = input.nextDouble();
expense = rent+utility+transport;
net = gross - expense;
System.out.println("You have " + "$ " + net + " left to invest in");
System.out.println("The Highest Stock Listed Is: " + highestShare(net, perShare) + " shares" + company[indexOfHighest]);
}
}