Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class HelloWorld
- {
- public static void main(String[] args)
- {
- Scanner in = new Scanner(System.in);
- int nw = 10000;
- System.out.println("\tWelcome to Wall Street's\n\t\tStock Exchange");
- String company[] = {"Apple", "Tesla", "Microsoft", "Google","SpaceX","Amazon","Meta","Twitter","Snapchat","Neuralink"};
- int stockp[] = {100,90,80,70,60,50,80,30,30,20};
- while (nw>0)
- {
- for(int i=0; i<10; i++)
- {
- int changev = (int)(Math.random()*100)+1;
- int changes = (int)(Math.random()*3)+1;
- if (changes == 1)
- stockp[i] += changev;
- else if (changes == 2)
- stockp[i] -= changev;
- else
- continue;
- }
- for(int i=0; i<10; i++)
- {
- int j = i+1;
- System.out.println(j + ". " + company[i]+":"+"\t"+stockp[i]);
- }
- System.out.println("Enter the sl.no. of Company: ");
- int sn = in.nextInt();
- int p = stockp[sn-1];
- System.out.println("Enter the no. of stocks bought:");
- int sb = in.nextInt();
- nw -= (p*sb);
- System.out.println("Your new Net Worth: " + nw);
- for(int i=0; i<10; i++)
- {
- int changev = (int)(Math.random()*100)+1;
- int changes = (int)(Math.random()*3)+1;
- if (changes == 1)
- stockp[i] += changev;
- else if (changes == 2)
- stockp[i] -= changev;
- else
- continue;
- }
- for(int i=0; i<10; i++)
- {
- int j = i+1;
- System.out.println(j + ". " + company[i]+":"+"\t"+stockp[i]);
- }
- int ch = stockp[sn-1]-p;
- nw += (p+ch)*sb;
- System.out.println("Your new Net Worth: " + nw);
- System.out.println();
- System.out.println("Press 1 to exit");
- int d = in.nextInt();
- System.out.println();
- if (d==1)
- System.exit(0);
- else
- continue;
- }
- System.out.println("You are BANKRUPT!!");
- }
- }
Add Comment
Please, Sign In to add comment