/* The java program that prompts user to enter the
price list of the stock price. Then find the lowest and highest
price
* and its day on lowest and highest .Print the result of
highest and lowest price of stock prices and its day *
*/
//StockMarket.java
import java.util.Scanner;
public class StockMarket
{
public static void main(String[] args)
{
//declare variables of
integer type
int lowest;
int lowestDay;
int highest;
int highestDay;
//create a object of
Scanner class
Scanner console=new
Scanner(System.in);
System.out.printf("Please enter
stock prices: ");
String
prices=console.nextLine();//raed prices as string
//split prices by split
method by comma as delimiter
String
priceList[]=prices.trim().split(",");
//Assume starting value in
priceList is lowest
//and highest values of
stock prices
lowest=Integer.parseInt(priceList[0]);
lowestDay=0;
highest=Integer.parseInt(priceList[0]);
highestDay=0;
/*Now update the lowest and
highest and its
* days inside the for loop
*/
for (int day = 1; day <
priceList.length;day++)
{
int
update_price=Integer.parseInt(priceList[day]);
//update
the lowest and lowestDay
if(update_price<lowest)
{
lowest=update_price;
lowestDay=day;
}
//update
the highest and highest day
if(update_price>highest)
{
highest=update_price;
highestDay=day;
}
}
//print the highest and
lowest on day values
System.out.println("Highest price:
"+highest+" occurred on day # "+highestDay);
System.out.println("Lowest price:
"+lowest+" occurred on day # "+lowestDay);
}
}
-----------------------------------------------------------------------------------------------------------------------------
Sample Output:
Sample run1:
Please enter stock prices: 1,22,30,38,44,49,73,52,66
Highest price: 73 occurred on day # 6
Lowest price: 1 occurred on day # 0
Sample run2:
Please enter stock prices: 41,37,40,54,51,63,54,47,23,33
Highest price: 63 occurred on day # 5
Lowest price: 23 occurred on day # 8
Problem 7. Stock Market For this program you are given a String that represents stock prices...
USE JAVA
Problem 1: Guess a Number You are writing a program for a number guessing game. For playing "Guess a Number", the program will generate a number for player to guess from within a range specified by the player. The program will take as input the lowest number in the range and the highest number in the range from the player, and then a series of guesses of the form: <n,>n, = n, where n is the number guessed....
In the first task, you will write a Java program that accepts a string of the format specified next and calculate the answer based on the user input. The input string should be of the format dddxxdddxx*, where d represents a digit and x represents any character and asterisk at the end represents that the string can have any number of characters at the end. 1. Prompt the user to enter a string with the specific format (dddxxdddxx*) 2. Read...
WRITE JAVA PROGRAM Problem Statement You are required to write a stock price simulator, which simulates a price change of a stock. When the program runs, it should do the following: Create a Stock class which must include fields: name, symbol, currentPrice, nextPrice, priceChange, and priceChangePercentage. The Stock class must have two constructor: a no-argument constructor and a constructor with four parameters that correspond to the four fields. o For the no-argument constructor, set the default value for...
Write a python function score_formatter() that takes one parameter, which is a formatted string that contains information about the score received by a student in a particular subject. The function analyzes the string and returns a reformatted string for the score. You will need to use the function re.sub that is discussed in the lecture notes. If the string does not match the pattern, the function returns the string "error". The input string is always given in the format specified...
Suppose you are given the following information about a particular industry: Market demand Market supply QD = 14400 - 100P QS = 1500P C(a)=673 + 20 MC(q) = 200 Firm total cost function Firm marginal cost function. Assume that all firms are identical and that the market is characterized by perfect competition. Find the equilibrium price, the equilibrium quantity, the output supplied by the firm, and the profit of each firm. The equilibrium price is $ 9. (Enter your response...
ANY HELP PLEASE. PLEASE READ THE WHOLE INSTRUCTION THANK YOU Write a program GS.java that will be responsible for reading in the names and grades for a group of students, then reporting some statistics about those grades. The statistics to be gathered are the number of scores entered, the highest score and the name(s) of the student(s) who earned that score, the lowest score and the name(s) of the student(s) who earned that score, and the average score for the...
With this program you are going to design a math practice program for younger users. You will ask the user to enter two numbers. Only numbers may be entered. If the user enters a word, the program should disregard the entry and wait for an integer entry. There will not be another prompt if the user enters data other than whole numbers (integers). Here is a sample run: Your static methods should accept two integers and return an integer. Do...
How do you write out this C++ program and zip the files?
A local department store is having a BoGoHo (Buy One, Get One Half Off) sale. The store manager wants a program that allows the salesclerk to enter the prices of two items. The program should calculate and display the total amount the customer owes. The half-off should always be taken on the item having the lowest price. For example, if the items cost $24.99 and $10, the half-off...
Write in C
Spring 2016 Lab Assignment 11 ET2100 In computer programming in general a "string" is a sequence of characters. In the C language anything within double quotes is a "string constant" so you have been seeing strings all semester. But we can also have string variables. In the C language these are implemented as an array of char, e.g. char name (10]: In order to make these variables easier to work with, it has been universally agreed that...
Problem: You will write a program to compute some statistics based on monthly average temperatures for a given month in each of the years 1901 to 2016. The data for the average August temperatures in the US has been downloaded from the Climate Change Knowledge Portal, and placed in a file named “tempAugData.txt”, available on the class website. The file contains a sequence of 116 values. The temperatures are in order, so that the first one is for 1901, the...