Download Horizon :: Staff Members :: Save Vault :: XboxMB YouTube


Old 09-20-2012   #1 (permalink)
Regular Member
Wookie's Avatar
Join Date: Jan 2012
Location: United States
Posts: 700
Thanks: 312
Default Java Classwork, Help

Click the spoiler for my classwork



Do not write the code, if you do it for me, then I won't learn anything forcing me to go back to my teacher for more help . Just try to explain it to me step by step. Thanks , my grade is a 100% in Java class ,I'm trying to keep it!
__________________

Last edited by Wookie; 09-21-2012 at 08:31 AM.
Wookie is offline Send a message via AIM to Wookie
Reply With Quote


Old 09-20-2012   #2 (permalink)
Regular Member
kill_seth's Avatar
Join Date: Oct 2010
Location: MyXboxSaves
Posts: 800
Thanks: 613
Default Re: Java Ckasswork, Help

1. It's asking you to code a program that executes the following function: 3X 2 -8X + 4
"I assume that is: ((3.0*x) * 2.0 - (8.0*x) + 4.0)" //Put .0 to make all numbers double.

2. You must create a double variable and store the number you want to use for x.
("like double x = 3.0"

3. Then you need to create a new double variable which will hold the result of the function.
(like double result = "((3.0*x) * 2.0 - (8.0*x) + 4.0)"

4. Then you just need to display the result.
"like System.out.println("At x = " + x + " the value is: " + result)"
kill_seth is offline Send a message via AIM to kill_seth
Reply With Quote
The following user thanked this post: Wookie


Old 09-20-2012   #3 (permalink)
SPEED's Avatar
Join Date: Sep 2010
Posts: 868
Thanks: 1,291
Default Re: Java Ckasswork, Help

Initialize x as a double equal to 4.0

Initialize result as a double equal to the math, which you need to figure out how to do (or not, since Seth gave it to you)

For example: double result = 3*(xval);
That would set result = 12.0 if xval = 4.0

Then just put it all together.. System.out.print("At X = "+xval+", the value is "+result);

Last edited by SPEED; 09-20-2012 at 09:52 AM.
SPEED is online now
Reply With Quote
The following user thanked this post: Wookie




Old 09-21-2012   #4 (permalink)
Regular Member
Wookie's Avatar
Join Date: Jan 2012
Location: United States
Posts: 700
Thanks: 312
Default Re: Java Ckasswork, Help

Quote:
Originally Posted by kill_seth View Post
1. It's asking you to code a program that executes the following function: 3X 2 -8X + 4
"I assume that is: ((3.0*x) * 2.0 - (8.0*x) + 4.0)" //Put .0 to make all numbers double.

2. You must create a double variable and store the number you want to use for x.
("like double x = 3.0"

3. Then you need to create a new double variable which will hold the result of the function.
(like double result = "((3.0*x) * 2.0 - (8.0*x) + 4.0)"

4. Then you just need to display the result.
"like System.out.println("At x = " + x + " the value is: " + result)"

Quote:
Originally Posted by SPEED View Post
Initialize x as a double equal to 4.0

Initialize result as a double equal to the math, which you need to figure out how to do (or not, since Seth gave it to you)

For example: double result = 3*(xval);
That would set result = 12.0 if xval = 4.0

Then just put it all together.. System.out.print("At X = "+xval+", the value is "+result);




My next task.


Modify the program in exercise 2 so that one run of the program will evaluate and write out the value of the quadratic for three different values of X: 0.0, 2.0, and 4.0 (or any three values of your choice.)
Write the program using the following equation.
.5x2 - 3x - 14
In writing the program make use of your editor's "copy" and "paste" functions to avoid re-typing similar lines.
__________________

Last edited by Wookie; 09-21-2012 at 08:46 AM.
Wookie is offline Send a message via AIM to Wookie
Reply With Quote


Old 09-21-2012   #5 (permalink)
SPEED's Avatar
Join Date: Sep 2010
Posts: 868
Thanks: 1,291
Default Re: Java Ckasswork, Help

Quote:
Originally Posted by Wookie View Post
My next task.


Modify the program in exercise 2 so that one run of the program will evaluate and write out the value of the quadratic for three different values of X: 0.0, 2.0, and 4.0 (or any three values of your choice.)
Write the program using the following equation.
.5x2 - 3x - 14
In writing the program make use of your editor's "copy" and "paste" functions to avoid re-typing similar lines.
Since he just wants you to copy/paste it, just do it like so:

double x1 = 0.0; //you really might as well make these int x1=0; etc
double x2 = 2.0;
double x3 = 4.0;

double x1Result = math*x1;
double x2Result = math*x2;
double x3Result = math*x3;

System.out.print(x1Result+",\n"+x2Result+",\n"+x3R esult);
SPEED is online now
Reply With Quote


Old 09-26-2012   #6 (permalink)
Regular Member
Wookie's Avatar
Join Date: Jan 2012
Location: United States
Posts: 700
Thanks: 312
Default Re: Java Ckasswork, Help

Quote:
Originally Posted by SPEED View Post
Since he just wants you to copy/paste it, just do it like so:

double x1 = 0.0; //you really might as well make these int x1=0; etc
double x2 = 2.0;
double x3 = 4.0;

double x1Result = math*x1;
double x2Result = math*x2;
double x3Result = math*x3;

System.out.print(x1Result+",\n"+x2Result+",\n"+x3R esult);
I don't understand this. I use int 0 for this correct?

Write a program that averages the rain fall for three months, April, May, and June. Declare and initialize a variable to the rain fall for each month. Compute the average, and write out the results, something like:
Rainfall for April: 12
Rainfall for May : 14
Rainfall for June: 8
Average rainfall: 11.333333
To get the numerical values to line up use the tabulation character '\t' as part of the character string in the output statements. Check that your program prints the correct results. There is a beginner's error lurking in this program too! Did you fall victim to it?
__________________
Wookie is offline Send a message via AIM to Wookie
Reply With Quote


Old 09-26-2012   #7 (permalink)
SPEED's Avatar
Join Date: Sep 2010
Posts: 868
Thanks: 1,291
Default Re: Java Classwork, Help

Code:
        int rainApril = 12;
        int rainMay = 14;
        int rainJune = 8;
        
        double rainAvg = (double)(rainApril+rainMay+rainJune)/3; //cast as double to return correct results, not casting results in a rounded number
        
        System.out.println("\tRainfall for April: "+rainApril);
        System.out.println("\tRainfall for May: "+rainMay);
        System.out.println("\tRainfall for June: "+rainJune);
        System.out.println("\tAverage Rainfall: "+rainAvg);
SPEED is online now
Reply With Quote


Old 09-26-2012   #8 (permalink)

Konor's Avatar
Trollface.
Join Date: Sep 2010
Location: Nottingham, UK
Posts: 2,133
Thanks: 1,367
Default Re: Java Classwork, Help

Quote:
Originally Posted by SPEED View Post
Code:
        int rainApril = 12;
        int rainMay = 14;
        int rainJune = 8;
        
        double rainAvg = (double)(rainApril+rainMay+rainJune)/3; //cast as double to return correct results, not casting results in a rounded number
        
        System.out.println("\tRainfall for April: "+rainApril);
        System.out.println("\tRainfall for May: "+rainMay);
        System.out.println("\tRainfall for June: "+rainJune);
        System.out.println("\tAverage Rainfall: "+rainAvg);
Quote:
Originally Posted by Wookie
Do not write the code, if you do it for me, then I won't learn anything forcing me to go back to my teacher for more help . Just try to explain it to me step by step. Thanks , my grade is a 100% in Java class ,I'm trying to keep it!
Not sure if you were giving him the code, or not.
So I copied that.
__________________




Konor is offline Send a message via AIM to Konor
Reply With Quote
The following user thanked this post: Wookie


Old 09-26-2012   #9 (permalink)
SPEED's Avatar
Join Date: Sep 2010
Posts: 868
Thanks: 1,291
Default Re: Java Classwork, Help

Quote:
Originally Posted by Konor View Post
Not sure if you were giving him the code, or not.
So I copied that.
I feel like **** right now and don't feel like taking the time to explain everything, so I just gave him the code and commented what he should need to know. It's a basic program, so he should be able to read my code and learn from it.
SPEED is online now
Reply With Quote
The following user thanked this post: Wookie

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:41 AM.


 

Powered by vBulletin® Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
COPYRIGHT (c) 2010 - 2013 - XboxMB - DESIGN BY:
EDENWEBS.COM