Welcome, Guest. Please login or register.
Did you miss your activation email?
Pages: [1]   Go Down
  Print  
Author Topic: Java stock project help URGENT  (Read 830 times)
0 Members and 1 Guest are viewing this topic.
JavaLearner
Member
*

Reputation: 0
Offline Offline
Posts: 34
Referrals: 0

Awards
« on: July 05, 2009, 04:40:27 AM »

need help on a java project, i am still a beginner so i havent learnt alot of advanced techniques yet,i have taken a screenshot of the questions as it is hard to explain it.

http://i27.photobucket.com/albums/c199/Kyrogue/java/scan0003.jpg
Java stock project help URGENT

and i have done these, i am stuck on if the user enters choice 2 the program will display existing stock information and prompt user to update share price,help is appreciated
Code
GeSHi (java):
  1. /*Chin Zhi Qiang
  2.  *Computer programming Project
  3.  */
  4. import java.util.Scanner;
  5.  
  6. class ChinZhiQiang {
  7.   static final double capital = 100000.00;//starting capital
  8.  
  9. public static void main(String args[]){
  10. /////Variables////
  11. Scanner myScanner = new Scanner(System.in);
  12. int choice;
  13.  
  14.    /////Menu/////
  15. System.out.println("\tStock Portfolio\t");
  16. System.out.println("======================================");
  17. System.out.println("1) Select 1 to create stock portfolio.");
  18. System.out.println("2) Select 2 to update share price.");
  19. System.out.println("3) Select 3 to exit.");
  20. /////Prompt Input/////
  21. System.out.print("Please enter your choice(1 - 3): ");
  22. choice = myScanner.nextInt();
  23.  
  24. if(choice == 1){
  25. portFolio();
  26. }
  27. if(choice == 2){
  28. updateSharePrice();
  29. }
  30. if(choice == 3){
  31. System.out.println("Thanks for using");
  32. }
  33. }
  34.  
  35. static  void portFolio(){/////portFolio method/////
  36. Scanner portFolioScanner = new Scanner(System.in);
  37. int stocksToCreate =0;
  38. double stockUnitPrice = 0;
  39. int stockUnit = 0;
  40. String stockName, stockSym;
  41. int modify;
  42.  
  43. System.out.print("Number of stocks in your portfolio (max 99): ");
  44. stocksToCreate = portFolioScanner.nextInt();
  45. System.out.println();//line break
  46. do
  47. {
  48.  
  49. System.out.print("Please Enter Stock name ( between 8 and 14 characters ): ");
  50. stockName = portFolioScanner.next();
  51. System.out.print("Please Enter 3 or 4 letter stock symbol: ");
  52. stockSym = portFolioScanner.next();
  53. System.out.print("Please Enter unit price: ");
  54. stockUnitPrice = portFolioScanner.nextDouble();
  55. System.out.print("Please Enter no. of units bought: ");
  56. stockUnit = portFolioScanner.nextInt();
  57. System.out.println();// line break
  58.  
  59. System.out.println("You have entered: ");
  60. System.out.println(stockName+"\t"+stockSym+"\t"+stockUnit+" units\t"+"@ "+stockUnitPrice);
  61.  
  62. System.out.print("If Ok, enter 1 else enter 0 to modify: ");
  63. modify = portFolioScanner.nextInt();
  64. System.out.println();
  65.  
  66. }while(modify == 0);
  67.  
  68. System.out.print("--- Accepted --- Cash Value Left $:");
  69. System.out.print(capital - (stockUnit * stockUnitPrice));
  70. System.out.print("\n************************************\n");
  71.  
  72.  
  73. }/////End of portFolio method/////
  74.  
  75. static void updateSharePrice(){/////Start of updateSharePrice method/////
  76. System.out.println("Here is your current list of stocks : \n");
  77. System.out.print("\t\t\t\tBought Current Stock\n");
  78. System.out.println("Stock Name\tSymbol\tUnits\tPrice\tPrice\tValue ");
  79. System.out.print("----------\t------\t-----\t-----\t-----\t-----\n");
  80. // System.out.print(stockName);
  81.  
  82.  
  83. }
  84.  
  85. }
Created by GeSHI 1.0.7.20
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Your Ad Here