Discussion:
Helpppp plzzz
(too old to reply)
Sara M.
2013-02-21 18:30:08 UTC
Permalink
Hi guys ,
I am taking C.T.S this semester and I am stuck pleaseee help me..

Okay so there is this assignment from the blue pelican called mixed results

and says the following :

Project… Mixed Results
Create a new project called MixedResults with a class called Tester. Within the main method
of Tester you will eventually printout the result of the following problems. However, you
should first calculate by hand what you expect the answers to be. For example, in the
parenthesis of the first problem, you should realize that strictly integer arithmetic is taking
place that results in a value of 0 for the parenthesis.



double d1 = 37.9; //Initialize these variables at the top of your program
double d2 = 1004.128;
int i1 = 12;
int i2 = 18;
Problem 1: 57.2 * (i1 / i2) +1
Problem 2: 57.2 * ( (double)i1 / i2 ) + 1
Problem 3: 15 – i1 * ( d1 * 3) + 4
Problem 4: 15 – i1 * (int)( d1 * 3) + 4
Problem 5: 15 – i1 * ( (int)d1 * 3) + 4





So I wrote this in Netbeans but I get the error expected !!

this is what i wrote in netbeans !!





/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mixedresults;

/**
*
* @author •SaRa•
*/
public class Tester {

public static void main(String []args)
{
final double d1=37,9;

double d1 = 37.9;
double d2=1004,128;
int i1=12;
int i2=18;

Problem 1: 57.2*(i1/i2)+1;
Problem 2: 57.2*((double)i1/i2)+1;
Problem 3: 15-i1*(d1*3)+4;
Problem 4: 15-i1*(int)(d1*3)+4;
Problem 5: 15-i1*((int)dl*3)+4;

}

}
Eric Sosman
2013-02-21 18:57:30 UTC
Permalink
Post by Sara M.
[...]
package mixedresults;
/**
*
*/
public class Tester {
public static void main(String []args)
{
final double d1=37,9;
Did you mean `37.9' instead of `37,9'? Java follows the
American practice of using `.' instead of `,' between the
integer and fraction parts.
Post by Sara M.
double d1 = 37.9;
This defines a variable named `d1', but a `d1' variable
has already been defined -- You can't define a second `d1'
here. Either fix the first line and delete this one, or
delete the first line.
Post by Sara M.
double d2=1004,128;
Same `.' vs. `,' problem as before.
Post by Sara M.
int i1=12;
int i2=18;
Problem 1: 57.2*(i1/i2)+1;
Problem 2: 57.2*((double)i1/i2)+1;
Problem 3: 15-i1*(d1*3)+4;
Problem 4: 15-i1*(int)(d1*3)+4;
Problem 5: 15-i1*((int)dl*3)+4;
These five lines aren't Java; they're just copied from
the problem statement. Apparently the intent is for you to
write Java statements that perform these calculations (and
print the results, probably). If you run into trouble writing
those statements, post what you've tried along with any error
messages you get, and someone will try to help you.
Post by Sara M.
}
}
--
Eric Sosman
***@comcast-dot-net.invalid
Roedy Green
2013-02-22 02:13:04 UTC
Permalink
On Thu, 21 Feb 2013 10:30:08 -0800 (PST), "Sara M."
Post by Sara M.
his is what i wrote in netbeans !!
You have to ask a question. See http://mindprod.com/newsgroups.html
--
Roedy Green Canadian Mind Products http://mindprod.com
The generation of random numbers is too important to be left to chance.
~ Robert R. Coveyou (born: 1915 died: 1996-02-19 at age: 80)
Lew
2013-02-22 02:31:19 UTC
Permalink
Post by Roedy Green
You have to ask a question. See http://mindprod.com/newsgroups.html
She did, implicitly. Surely you figured that out.

However, she would benefit more from
http://www.catb.org/esr/faqs/smart-questions.html

Lady, "pleaseeee" is not a word, it's a whine (on the silent "e" no less).

"Helpppp" and "plzzz" are also not words.

You don't even usually need exclamation points, let alone several in a row.

Read the Java tutorials. You're supposed to try to learn the language first,
then try to write code in accordance with the language's rules. You have not
yet even tried to make your code look like Java, let alone to write valid Java.

http://docs.oracle.com/javase/tutorial/

Study. Learn. Do. Share the knowledge.
--
Lew
Daniel Pitts
2013-02-22 18:00:32 UTC
Permalink
Post by Sara M.
Hi guys ,
I am taking C.T.S this semester and I am stuck pleaseee help me..
There are zero z's, and only two e's in the word please. Also, help only
has one p.

You may be under the impression that repeating letters add emphasis to
your desire to be helped. If it adds anything, its a sense of whining.
My young daughter knows that whining is the surest way to *not* get
any help. This abuse of the language also creates the impression that
you can't take the time to think carefully about a problem, and that you
want us just to do your homework for you.

Hopefully you've left plenty of time to solve the homework yourself,
because on this group you'll find only suggestions on how to approach
the problem, not actual solutions. This is for your own good. We've all
done this homework before. Us doing it for you serves no one.

Tell us what you've tried. Provide an SSCCE if applicable. Tell us what
part of the failure you've encountered, and what you think it should be
doing. Yes, we need you to think yourself. We can help you to think
differently, but only if we know how you think.

Good luck.

Daniel.
Roedy Green
2013-02-24 08:17:58 UTC
Permalink
On Thu, 21 Feb 2013 10:30:08 -0800 (PST), "Sara M."
Post by Sara M.
Problem 1: 57.2*(i1/i2)+1;
Problem 2: 57.2*((double)i1/i2)+1;
Problem 3: 15-i1*(d1*3)+4;
Problem 4: 15-i1*(int)(d1*3)+4;
Problem 5: 15-i1*((int)dl*3)+4; =20
This does not look much like Java.

You can't use spaces in labels.

You must print out expressions or put them in variables. Just
computing them is nearly always pointless.
--
Roedy Green Canadian Mind Products http://mindprod.com
The generation of random numbers is too important to be left to chance.
~ Robert R. Coveyou (born: 1915 died: 1996-02-19 at age: 80)
Loading...