Forums

ForumsProgramming Forum

Programming Class

Posted Jul 25, '12 at 2:12pm

Darkroot

Darkroot

2,879 posts

@maninfrontothemask Yeah I forgot about that part but it is a simple process.

@gunsofliberty I think it is easier just to post things here. I wasn't even sure some of the messages were received on gmail.

 

Posted Jul 25, '12 at 4:03pm

AceofSky

AceofSky

782 posts

Never specified a timezone or if it follow your mortal clocks. My "today" lasts from 6 am to 6 pm PST it's only 9:30 pm or 21:30 here. :P
Anyway the assignment. Will be due by Sunday 6:00 PM or 18:00 PST
Make a short program that calculates the Quadratic equation using the values a,b,c which you will instantiate and fill will some numbers. You can assume the user will be reasonable with the inputs (not applicable to real life users are extremely dumb don't trust them, if you let them divide by zero they will). There will be two outputs of the roots that you got in the calculations since quadratic equation has +- applied at the same time thus two answers/roots. The form of the output will be,
The first output is, "X"
The second output is, /Y/
This assignment will also require you read Section 2.3

So your saying...hmmm im not sure I can post the equation for a regular Quadratic Equation, but do you mean as in using the Quadratic formula to somehow create a program which when the user inputs a quadratic equation it'll display the roots? I think I just dumbed it down for myself...

Anyways, I will be not able to respond over the next following days, since Iam coming back home. Other than that, all I ask is for extra time. I just have enough time to post this message and then get off -_-
 

Posted Jul 25, '12 at 5:44pm

Darkroot

Darkroot

2,879 posts

I probably will have to extend it since I think I need to email a couple of people on the email-list since they probably don't know the assignment here. Also no you got it wrong. When users inputs (changes the vars inside the program no real i/o. Then the quadratic equation program calculates it. It's not very hard you don't even need to understand how the equation works just make the math in the program work. For square roots you will need to read 2.3 and how to perform some of the more complicated math operations in java.

 

Posted Jul 26, '12 at 12:15am

maninfrontofthemask

maninfrontofthemask

99 posts

So... just to dot the i's and cross the t's. Assignment one is to create a program with values a,b,c to create the standard quadratic equation, y=ax^2+bx+c and then output the x values of the 2 roots (where the y-value is 0) to the standard output. Also referring to your last post a,b,c don't actually have to be inputted, we can just manipulate their values in the program.

Does that sound right? I also tried to relay as much info as I could to the perhaps not mathematically inclined students

 

Posted Jul 26, '12 at 2:53am

Darkroot

Darkroot

2,879 posts

Yeah that sounds like you understand what you have to do.

If anyone still doesn't understand what is supposed to be done or how to program it don't hesitate to ask.

 

Posted Jul 26, '12 at 9:30am

maninfrontofthemask

maninfrontofthemask

99 posts

K sorry I feel like a bother but what do you want us to do with our program when we are done?

 

Posted Jul 26, '12 at 12:23pm

Darkroot

Darkroot

2,879 posts

System.out.println(); both of these messages:

The first output is, "X"
The second output is, /Y/
 

Posted Jul 29, '12 at 9:17pm

gunsofliberty

gunsofliberty

28 posts

Dark, I'm having some problems,


public class Math {

public static void main(String[] args) {
int x = 1;
int y = 0;
int ax = 6;
int bx = 3;
int c = 2;


y=ax^2+bx+c;

System.out.print( Math.sqrt(x) );
System.out.println ('The first output is, "x")
System.out.println ('The second output is, y)
}
}


12 errors. I'm doing this horribly,

 

Posted Jul 30, '12 at 5:46am

Xzeno

Xzeno

2,354 posts

Main method in a math class... interesting... the Math class already exists in Java. Don't know if that's a source of errors or not.


y=ax^2+bx+c;
The syntax is entirely wrong here. to square something, you can't use "^2". I think there's a Math method to do it, but it's usually more efficient to multiply it by itself: y = ax * ax + bx + c; should work. No need for parenthesis because the order of operations holds.

System.out.print( Math.sqrt(x) );
System.out.println ('The first output is, "x")
System.out.println ('The second output is, y)
Problems abound here. First of all, you need to use double quotation marks: "" for string literals. Single quotes are for character literals. Now, if you want to print the value contained in x, you can't put it in quotes: then it will print the letter x. Rather, you must concatenate the int x to the string literal with the + operator. Try:

System.out.println( "The first output is " + x );

That code would print this: "The first output is 1

For the next line, you'll do something similar.

System.out.println( "The second output is " + y );

If that doesn't solve your issues and you still get an error, it's probably because you can't pass the Math.sqrt method an integer value. Not sure on that one. If that's causing it to throw an exception, cast it to a double.

This advice won't give you the 100% correct output to dark's instructions: you still need to somehow get the double quotes around the x value and the / around the y. I'm sure Dark or I will help you with that if you need it.

Oh hey Darkroot. Mind if I help you with this a little?
 

Posted Jul 30, '12 at 9:04am

maninfrontofthemask

maninfrontofthemask

99 posts

[quote]System.out.println ('The first output is, "x")
System.out.println ('The second output is, y)

Also you are missing semicolon's at the end of the lines

 
Reply to Programming Class

You must be logged in to post a reply!