Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Write a java program

BunkerHillBroad
BunkerHillBroad 


Write a Java program to compute the largest increase that occurred in the price of a stock during a 10-day period. The program should read from a keyboard Scanner any 10 integers that represent stock prices, e.g., 48 54 49 47 62 64 59 70 75 82 and then print a message like Largest increase of 15 from 47 to 62 occurred between day #4 and day #5. You must design your program in such a way that to change the number of days from 10 to 30 (for example) merely requires changing one constant (final variable) declaration. Be sure your program does something reasonable if the price never increases! You may write the entire program using a just main method. You are not allowed to use an Array, ArrayList or even 10 variables to store the prices. You will get no credit for such a solution. Attachments
Tags Clarifications

Answers

Solution

mariobeka
mariobeka 



Implemented as stated in the question. Attachments
LargestStockIncrease.java (1 K) Download Preview
currentDayStock && stockIncrease < (nextDayStock - currentDayStock)) { stockIncrease = nextDayStock - currentDayStock; count = i; currentValue = currentDayStock; currentDayStock = nextDayStock; } else { currentDayStock = nextDayStock; } } if (stockIncrease == 0) { System.out.println("No increase was found."); } else {

Screenshots
Purchase Answer