forked from Denisolt/CSCI-160
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwallStreet.java
More file actions
90 lines (85 loc) · 2.9 KB
/
wallStreet.java
File metadata and controls
90 lines (85 loc) · 2.9 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
package StockMarket;
/****************************************************
*Project Inormaiton
*Course: CSCI 185/504 Spring 2016
*Project Name: Project #1
*File Name: wallStreet
*Author:
*Date Created: 02/05/2016
*Date Updated: 02/19/2016 There are some changes for the class wallStreet where a new class or variable has been added.
*Description: This project will allow the user to enter his choice and select his company to trade with (Dow Joend, NASDAQ, and S&P 500)
* The project will print out the number of shares and the toatal price.
*****************************************************************************************************************************************/
import java.util.Scanner;
public class wallStreet
{
public int currentDow;
public int closePriceDow;
public int openPriceDow;
public int lowPriceDow;
public int currentNas;
public int closePriceNas;
public int openPriceNas;
public int lowPriceNas;
public int currentSp;
public int closePriceSp;
public int openPriceSp;
public int lowPriceSp;
public int numberOfShares = 0;
public int totalPriceforDow = 0;
public int totalPriceforNas = 0;
public int totalPriceforSP = 0;
public int numberOfSharesDow = 0;
public int numberOfSharesNas = 0;
public int numberOfSharesSP = 0;
public int totalPrice = 0;
public boolean again;
Scanner keyboard = new Scanner (System.in);
public void marketPlace(String company)
{
enterTrade(company);
}
public void enterTrade(String company)
{
again = false;
switch (company.toUpperCase())
{
case "DOW":
if(currentDow> openPriceDow && closePriceDow < lowPriceDow)
{
System.out.print("number of shares: ");
int buy = keyboard.nextInt();
numberOfSharesDow += buy;
totalPriceforDow += numberOfSharesDow * currentDow;
}
else
again = false;
break;
case "NAS":
if(currentNas> openPriceNas && closePriceNas < lowPriceNas)
{
System.out.print("number of shares: ");
int buy = keyboard.nextInt();
numberOfSharesNas += buy;
totalPriceforNas += numberOfSharesNas * currentNas;
}
else
again = false;
break;
case "SP":
if(currentSp> openPriceSp && closePriceSp < lowPriceSp)
{
System.out.print("number of shares you wish to: ");
int buy = keyboard.nextInt();
numberOfSharesSP += buy;
totalPriceforSP += numberOfSharesSP * currentSp;
}
else
again = false;
break;
default:
again = false;
break;
}
}
}