3 Replies - 1346 Views - Last Post: 21 September 2013 - 07:51 PM Rate Topic: -----

#1 eyakin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 21-September 13

Assignment Help

Posted 21 September 2013 - 07:02 PM

Hi, I'm kinda new here. So yea I'm taking programming I and I have this assignment about Stock Transaction Program but seems like I messed up something here.

So the questions are :

The number of stocks Joe purchased was 1000
When Joe purchased the stock he paid $32.87 per share
Joe paid a broker 2% of stock's cost

Two weeks later Joe sold the stock. Here are the details:
The number of shares Joe sold was 1,000
He sold them for $33.92/share
He paid the broker 2%

Write a program that displays the following info:
The amount Joe paid for the stock
The amount of commision paid when Joe bought the stock
The amount Joe sold the stock for
The amount of commision paid his broker when he sold the stock
Display the amount of profit Joe made after selling his stock and paying the commisions

The code so far ...
import.java.util.Scanner;

public class StockTransaction 
{
	public static void main (String[]args) 
	{

	int numberOfShares;
	double sharePrice, origPrice, commis, totalPrice;

	Scanner scan = new Scanner(System.in);



	public void getValues()
    {
	System.out.prinIn("Please enter the price per share when they were bought: ");
	sharePrice = scan.nextDouble();

	System.out.prinIn("Please enter the number of shares bought: ");
	numberOfShares = scan.nextInt();


	public void displayResults() {
	System.out.printIn("Joe originally paid $" + origPrice);
	System.out.printIn("The Commission is $" + commis);
}






getting a lot of errors here ><

kty.

Is This A Good Question/Topic? 0
  • +

Replies To: Assignment Help

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10771
  • View blog
  • Posts: 40,102
  • Joined: 27-December 08

Re: Assignment Help

Posted 21 September 2013 - 07:27 PM

Welcome to Dream.in.Code! Moved to Java. Please do not post programming questions in the Student Campus forum. You will get better help by posting in the appropriate forum based on the language.

Please post your errors exactly as they appear.
Was This Post Helpful? 0
  • +
  • -

#3 MentalFloss  Icon User is offline

  • "ADDICTED"[2:5]
  • member icon

Reputation: 527
  • View blog
  • Posts: 1,397
  • Joined: 02-September 09

Re: Assignment Help

Posted 21 September 2013 - 07:46 PM

The first interesting thing to note is that based off of your problem, there is no input to be had. We already know every input so there is no reason to do any of that.

What this is testing is your ability to do the formulas to arrive at the solution.

The amount Joe paid for the stock (So, if he paid 32.87 per share and bought 1000 shares, how much did he pay?)

The amount of commision paid when Joe bought the stock (Joe paid a broker 2% of stock's cost so what is that based on what he paid?)

The amount Joe sold the stock for (The number of shares Joe sold was 1,000. He sold them for $33.92/share)

The amount of commision paid his broker when he sold the stock (He paid the broker 2%)

Display the amount of profit Joe made after selling his stock and paying the commisions (So, what is that formula?)

With those questions answered, you implement the code accordingly.

Maybe you have a method like getCommision(float take) that returns how much the broker gets based on a percent.

OR... maybe you just calculate all of these things on paper and make println statements that say them.

I wasn't in your lesson and I don't know the scope of this task's competency assessment.

Hope that helps.

This post has been edited by MentalFloss: 21 September 2013 - 07:49 PM

Was This Post Helpful? 0
  • +
  • -

#4 Atspulgs  Icon User is offline

  • D.I.C Regular

Reputation: 68
  • View blog
  • Posts: 380
  • Joined: 29-July 09

Re: Assignment Help

Posted 21 September 2013 - 07:51 PM

import.java.util.Scanner;


Should be
import java.util.Scanner;

import is a keyword.

Next, youre missing close bracket } in the main method. Youre creating a new method before closing the main one. In fact youre not closing any of your methods.

System.out.prinIn

I assume you wanted to have
System.out.println


Then youre trying to access the variables from a different method. You should look into the variable scope. First result in google.

Also youre not calling the 2 methods :/ i dont know what you expect to do with them.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1