Re: Help with Java in Netbeans
Sara M. wrote:
okay so I have this assignment and
Are there teachers? Teaching assistants?
this is what they want from me :
They want you to come to them for help.
Project=85 Mixed Results
Create a new project called MixedResults with a class called Tester. With=
in the main method
of Tester you will eventually printout [sic] the result of the following =
problems. However, you
should first calculate by hand what you expect the answers to be. For exa=
mple, in the
You haven't shown us this part of your work.
parenthesis [sic] of the first problem, you should realize that strictly =
integer arithmetic is taking
place that results in a value of 0 for the parenthesis [sic].
double d1 = 37.9; //Initialize these variables at the top of your progr=
am
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 =96 i1 * ( d1 * 3) + 4
Problem 4: 15 =96 i1 * (int)( d1 * 3) + 4
Problem 5: 15 =96 i1 * ( (int)d1 * 3) + 4
Your printout should look like the following:
Problem 1: 1.0
Problem 2: 39.13333333333333
Problem 3: -1345.39999999999
Problem 4: -1337
Problem 5: -1313
and I dont know how to get that !!!
Calculate the result of the expression, optionally assign the result to a v=
ariable,
then print out the value of the result along with the indicated label.
this is what I write in Netbeans :
You show the first two of those three steps.
public static void main(String []args)
Fix your indentation.
{
double d1 = 37.9; //Initialize these variables at the top of your =
program
double d2 = 1004.128;
int i1 = 12;
int i2 = 18;
final double PROGRAM1=57.2 * (i1 / i2) +1;
That variable name is not compliant with the Java naming conventions, nor w=
ith the instructions
for your problem.
Try "problem1" as a variable name, and similarly for the rest.
These variables don't really need to be 'final'.
final double PROGRAM2=57.2 * ( (double)i1 / i2 ) + 1;
final double PROGRAM3=15 =96 i1 * ( d1 * 3) + 4;
final double PROGRAM4=15 =96 i1 * (int)( d1 * 3) + 4;
final double PROGRAM5=15 =96 i1 * ( (int)d1 * 3) + 4;
Now print out the values of those variables, along with the labels the inst=
ructions requested.
}
}
but it is wrong so can someone tell me how to get the above print they ar=
e expecting !!
How wrong? Show us what you expected and what you got.
Questions end in a single question mark, not two exclamation points.
and I have another question ,
Should be in a separate post, then.
Create a new project called ArithmeticAssignment with a class called Test=
er that will calculate
and print the results of the following arithmetic problems:
How about you do the first problem first before you try to do another? Hm?
Really, doesn't your school have resources to which you can go for help?
--
Lew