Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- String tickerSymbol;
- Double price, average, total = 0.0;
- int count = 0;
- int i;
- double min = 99999, max = 0;
- System.out.print("Please enter the company's ticker symbol: ");
- tickerSymbol = input.nextLine().toUpperCase();
- for (i = 1; i <= 5; i++) {
- System.out.print("Please enter the closing price for day " + i + " : ");
- price = input.nextDouble();
- total += price;
- if (price > max) {
- max = price;
- }
- if (price < min) {
- min = price;
- }
- count++;
- }
- average = total / count;
- System.out.println("------Stock Information------");
- System.out.println("Ticker Symbol: " + tickerSymbol);
- System.out.println("Average closing price for week: " + average);
- System.out.println("The min is " + min);
- System.out.println("The max is " + max);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement