Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #2547 > unrolled thread

Help with Java in Netbeans

Started by"Sara M." <kasra.song@gmail.com>
First post2013-02-24 17:28 -0800
Last post2013-02-24 18:24 -0800
Articles 4 — 2 participants

Back to article view | Back to comp.lang.java.help


Contents

  Help with Java in Netbeans "Sara M." <kasra.song@gmail.com> - 2013-02-24 17:28 -0800
    Re: Help with Java in Netbeans "Sara M." <kasra.song@gmail.com> - 2013-02-24 17:50 -0800
      Re: Help with Java in Netbeans Lew <lewbloch@gmail.com> - 2013-02-24 18:17 -0800
    Re: Help with Java in Netbeans Lew <lewbloch@gmail.com> - 2013-02-24 18:24 -0800

#2547 — Help with Java in Netbeans

From"Sara M." <kasra.song@gmail.com>
Date2013-02-24 17:28 -0800
SubjectHelp with Java in Netbeans
Message-ID<569be3e1-1080-4d91-82bd-bb0cf035449b@googlegroups.com>
Hi,
okay so I have this assignment and 

this is what they want from me : 


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 



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 !!! 

this is what I write in Netbeans : 



public class Tester { 
      
    public static void main(String []args) 
 { 
      
      
     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; 
     final double PROGRAM2=57.2 * ( (double)i1 / i2 ) + 1; 
     final double PROGRAM3=15 – i1 * ( d1 * 3) + 4; 
     final double PROGRAM4=15 – i1 * (int)( d1 * 3) + 4; 
     final double PROGRAM5=15 – i1 * ( (int)d1 * 3) + 4; 
      
} 
    
} 


but it is wrong so can someone tell me how to get the above print they are expecting !! and I have another question  , 


Create a new project called ArithmeticAssignment with a class called Tester that will calculate 
and print the results of the following arithmetic problems: 


79 + 3 * (4 + 82 –68) – 7 +19 
(179 +21 +10) / 7 + 181 
10389 * 56 * 11 + 2246 


The printout should look like the following: 


79 + 3 * (4 + 82 - 68) -7 + 19 = 145 
(179 + 21 + 10) / 7 + 181 = 211 
10389 * 56 * 11 + 2246 = 6401870 


how do i get the whole formula in my print  ? I can only get the answer ....

[toc] | [next] | [standalone]


#2550

From"Sara M." <kasra.song@gmail.com>
Date2013-02-24 17:50 -0800
Message-ID<891e26a3-138c-4f10-b9e0-b130c849d7a1@googlegroups.com>
In reply to#2547
I know how to print it but it gives me a error the print is System.Out.Println(); but the last 3 lines of the code are having an issue that is what i dont get ! i dont see where the problem is 


and in the second assignment i dont get how you can print the whole formula cause in java when you type 5/2 you automatically get 2  and not the whole formula  5/2=2 .... I want to know how to print out the whole formula 

[toc] | [prev] | [next] | [standalone]


#2552

FromLew <lewbloch@gmail.com>
Date2013-02-24 18:17 -0800
Message-ID<0402a3fc-f8c1-48ac-89b9-e0c77c2a476b@googlegroups.com>
In reply to#2550
Sara M. wrote:
> I know how to print it but it gives me a error the print is System.Out.Println(); 

There's no such thing in java.lang.System.

Spelling counts in Java.

You know how to print what? What error does it give you? (Copy and paste, do not merely 
describe the error.)

You've been pointed to 
http://www.catb.org/esr/faqs/smart-questions.html
before, haven't you?

>  but the last 3 lines of the code are having an issue that is what i [sic] dont get ! i dont see where the problem is

What issue are they having?

> and in the second assignment i dont get how you can print the whole formula 

What do you mean by "the whole formula"?

> cause in java [sic] when you type 5/2 you automatically get 2 

Actually, no. When the program evaluates the expression '5/2' it evaluates to '2'.

It doesn't happen when you do anything, let alone type.

> and not the whole formula  5/2=2

What do you mean by "the whole formula"?

>  .... I want to know how to print out the whole formula

Do you mean you want to print the string "5/2 = 2"? Why didn't you say so?

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#2553

FromLew <lewbloch@gmail.com>
Date2013-02-24 18:24 -0800
Message-ID<3e5f34f5-f2de-4513-83ca-06e438f56d2d@googlegroups.com>
In reply to#2547
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… Mixed Results 
> Create a new project called MixedResults with a class called Tester. Within 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 example, 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 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 
> 
> 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 variable, 
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 with 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 – i1 * ( d1 * 3) + 4; 
>      final double PROGRAM4=15 – i1 * (int)( d1 * 3) + 4; 
>      final double PROGRAM5=15 – i1 * ( (int)d1 * 3) + 4; 

Now print out the values of those variables, along with the labels the instructions requested.

> } 
> } 
> 
> but it is wrong so can someone tell me how to get the above print they are 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 Tester 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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.help


csiph-web