Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. package com.company;
  2.  
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class Main {
  7.  
  8. public static void main(String[] args) {
  9. Scanner input = new Scanner(System.in);
  10. String tickerSymbol;
  11. Double price, average, total = 0.0;
  12. int count = 0;
  13. int i;
  14. double min = 99999, max = 0;
  15. System.out.print("Please enter the company's ticker symbol: ");
  16. tickerSymbol = input.nextLine().toUpperCase();
  17. for (i = 1; i <= 5; i++) {
  18. System.out.print("Please enter the closing price for day " + i + " : ");
  19. price = input.nextDouble();
  20. total += price;
  21. if (price > max) {
  22. max = price;
  23. }
  24. if (price < min) {
  25. min = price;
  26. }
  27. count++;
  28. }
  29.  
  30. average = total / count;
  31. System.out.println("------Stock Information------");
  32. System.out.println("Ticker Symbol: " + tickerSymbol);
  33. System.out.println("Average closing price for week: " + average);
  34. System.out.println("The min is " + min);
  35. System.out.println("The max is " + max);
  36.  
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement