Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please use Java and answer questions 3,4,5,6 Stock prices for companies fluctuat

ID: 3605738 • Letter: P

Question

Please use Java and answer questions 3,4,5,6

Stock prices for companies fluctuate multiple times during each day of trading. In this project we are going to write software for a financial company that keeps track of the stock prices. Following are the features provided by the company: 1. Register a client (business): Create unique ID and password, Name of Business, Current Stock price 2. Login a registered client: Upon successful login display the Name of the business, and the current stock price; login works only after registering 3. Provide option to log all the changes to the stock price, by adding the latest stock price and the time of the change 4. For the current day, display all the prices in reverse chronological order i.e., starting with the current price to the beginning price of the day 5. For the current day display the highest stock price that was attained, and the time 6. For the current day display the lowest stock price, and the time 7. Quit the session signaling the end of the day; the current stock price should be saved for the Business, so that when logging in the next day, that becomes the current stock price. Businesses open at 10:00 AM, so that should be the time of change for the first price of the day The program should be menu-driven; so until the user selects option 7 i.e., Quit, the program should keep executing. The program begins by registering a client if using the system for the first time; while registering only unique client ids are allowed and password must be at least 8 characters long. If the client cannot choose a unique id after 2 attempts, generate a random 8-character alphanumeric user id based on the name of the business. For clients previously registered, option 2 can be chosen directly Each stock price should be treated as an Object, and it should contain data about the previous price, the current price, and also the time of change to the current price

Explanation / Answer

package stockexchange;
import java.awt.Label;
import java.util.*;
/**
*
* @author Prashant Tomer
*/
public class StockExchange {

/**
* @param args the command line arguments
*
*
*/
  
  
static int cont()
{
int choice=0;
Scanner sc=new Scanner(System.in);
System.out.println("Enter 1.Registration 2.Login 3.change stock price 4.Prices list 5.highest stock price 7.exit");
  
choice=sc.nextInt();
return choice;
}
public static void main(String[] args) {
// TODO code application logic here
Stack info=new Stack();
String businessname;
double stockprice;
String id="";
String password="";
int count=0;
Map<String,String> logininfo=new HashMap();
Scanner sc=new Scanner(System.in);
  
switch(cont())
{
case 1:
System.out.println("Enter businessname & current stock price");
businessname= sc.next();

stockprice=sc.nextDouble();
System.out.println("Enter password for login");
password=sc.next();
System.out.println("Enter uniqueid for login");
for(int k=1;k<=2;k++)
{
id=sc.nextLine();
count++;
}
  
if(id.isEmpty() & count==2)
{
  
int b=(int)Math.floor(Math.random()*10000);
id=businessname.substring(0,4)+b;
logininfo.put(id,password);
}
else
logininfo.put(id,password);

info.add(businessname);
info.add(stockprice);
info.add(id);
info.add(password);

System.out.println("Successfully Register please note down ID and Password");
  

System.out.println("your details");
System.out.println(logininfo);
cont();
  
  
case 2:
System.out.println("enter id and password");
String id1=sc.next();
String pass=sc.next();
if(id1.equals(id) & pass.equals(password))
{
System.out.println("Login Successfully:");
System.out.println("Login Details Given Below:");
System.out.println(info);
}
cont();
  
case 7: System.exit(0);
}

}
  
}