Kasper123

Project

Sep 9th, 2025
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.Random;
  3. public class Project {
  4.     public static void main(String[] args) {
  5.         Scanner input = new Scanner(System.in);
  6.         Random rand = new Random();
  7.  
  8.         System.out.println("Enter name of Stock ==>");
  9.         String nameStock = input.nextLine();
  10.  
  11.         System.out.println("Enter symbol of Stock ==>");
  12.         String symbolStock = input.nextLine();
  13.  
  14.         int idStock = rand.nextInt(100);
  15.         Stock s1 = new Stock(symbolStock, nameStock, idStock);
  16.  
  17.         System.out.println("Enter previous closing price ==>");
  18.         s1.previousClosingPrice = input.nextDouble();
  19.  
  20.         System.out.println("Enter current price ==>");
  21.         s1.currentPrice = input.nextDouble();
  22.  
  23.         System.out.println("Stock name: " + s1.name);
  24.         System.out.println("Stock symbol: " + s1.symbol);
  25.         System.out.println("Stock ID: " + s1.ID);
  26.         System.out.println("Price-change percentage: " + s1.getChangePercent());
  27.     }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment