| | |
mutlipication table in java program
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
0
#2 Oct 6th, 2009
1) Create a array, which represents a table.
2) use a for loop;
2) use a for loop;
Java Syntax (Toggle Plain Text)
for(int i = 1; i != 5; i++) myArrayTable[i] = 6*i; //say, myArrayTable is already declared.
1) Prove that the area of a circle is pi*r^2, where "r" is the radius of the circle. 2) Problem 2[b]solved by : jonsca
0
#3 Oct 6th, 2009
•
•
•
•
1) Create a array, which represents a table.
2) use a for loop;
Java Syntax (Toggle Plain Text)
for(int i = 1; i != 5; i++) myArrayTable[i] = 6*i; //say, myArrayTable is already declared.
Why didn't you use this at the for loop:
Java Syntax (Toggle Plain Text)
for(int i = 1; i < 5; i++)
Check out my New Bike at my Public Profile at the "About Me" tab
•
•
Join Date: Oct 2009
Posts: 14
Reputation:
Solved Threads: 0
1)
Class: Multiply
Attributes: int x
int y
Methods: getters&setters
Constructors
toString
in Main
create array or arraylist of the class Multiply
take in the 2 numbers into each
to print:
iterate through the array and print the "Multiply.toString()" and the "toString()" will include the "x*y = z" to form each line
I would recomend using the IDE's BlueJ or Netbeans (Netbeans does most of it for you hence is my favourite)
any errors in my repllies then pm me please as I am also a learner
Class: Multiply
Attributes: int x
int y
Methods: getters&setters
Constructors
toString
in Main
create array or arraylist of the class Multiply
take in the 2 numbers into each
to print:
iterate through the array and print the "Multiply.toString()" and the "toString()" will include the "x*y = z" to form each line
I would recomend using the IDE's BlueJ or Netbeans (Netbeans does most of it for you hence is my favourite)
any errors in my repllies then pm me please as I am also a learner
0
#7 Nov 3rd, 2009
•
•
•
•
I have a question:
Why didn't you use this at the for loop:
Java Syntax (Toggle Plain Text)
for(int i = 1; i < 5; i++)
A thing to note ( at least in c++) is that != is more generic than
'<' because '!=' works with containers like vectors, string map
while '<' is not compatible with all of them. I imagine that
java is similar. It also depends on context btw.
1) Prove that the area of a circle is pi*r^2, where "r" is the radius of the circle. 2) Problem 2[b]solved by : jonsca
•
•
Join Date: Nov 2008
Posts: 63
Reputation:
Solved Threads: 4
0
#8 Nov 3rd, 2009
interesting point. I haven't seen the non-equals operator used as a loop conditional before. I have to admit that what you said makes sense. I would have never thought of it in that way before. But . . . what guarantee do you have that you are actually comparing values in c++? wouldn't a statement like objecta != objectb be interpreted as: The address where objecta resides is not equal to the address where objectb resides?
Besides, c++ allows you to overload your operators so there is no ambiguity. The classes you are talking about may have just implemented that.
But as far as comparing primitives? Sure != 5 looks hunky dory. I've been using comparison operators for the last 15 years, so I don't thnink I'll all of the sudden switch though.
Besides, c++ allows you to overload your operators so there is no ambiguity. The classes you are talking about may have just implemented that.
But as far as comparing primitives? Sure != 5 looks hunky dory. I've been using comparison operators for the last 15 years, so I don't thnink I'll all of the sudden switch though.
0
#9 Nov 3rd, 2009
>>
"what guarantee do you have that you are actually comparing values in c++?"
<<
In c++ the "!=" operator when used with container from std does not compare address like the "==" in java ( at times), it only compares
the values. The standard C++ library was implemented with generic in
mind.
"what guarantee do you have that you are actually comparing values in c++?"
<<
In c++ the "!=" operator when used with container from std does not compare address like the "==" in java ( at times), it only compares
the values. The standard C++ library was implemented with generic in
mind.
1) Prove that the area of a circle is pi*r^2, where "r" is the radius of the circle. 2) Problem 2[b]solved by : jonsca
•
•
Join Date: Nov 2008
Posts: 63
Reputation:
Solved Threads: 4
0
#10 Nov 3rd, 2009
•
•
•
•
In c++ the "!=" operator when used with container from std does not compare address like the "==" in java ( at times), it only compares
the values. The standard C++ library was implemented with generic in
mind.
c++ Syntax (Toggle Plain Text)
someCollection<someClass> someObject[] = new someCollection<someClass>()[2]; someObject[0] = someData; someObject[1] = otherData; if (someObject[0] != someObject[1]) { std::cout << "AHHHHHH!!!! Run for your lives!!! "; }
Also, c++ calls generic types template types. But you knew that.
So . . . should this thread be moved to c++ or did LKH get his answer? Sorry for the rambling.
Last edited by eggmatters; Nov 3rd, 2009 at 3:18 pm.
![]() |
Similar Threads
- put the Dos 's command into java program? (Java)
- Running java command thru java program (Java)
- help on this java program. (Java)
- Java program sample for getting Systeminfo (Java)
- JAVA program help (Student/Grades) (Java)
- Help with a java program home work assignment (Java)
Other Threads in the Java Forum
- Previous Thread: Java ActionListener Question
- Next Thread: Merging two files
Views: 492 | Replies: 11
| Thread Tools | Search this Thread |
Tag cloud for Java
911 addressbook android api append apple applet application arguments array arrays automation binary bluetooth character chat class classes client code component csv database detection draw eclipse error event exception file fractal ftp game givemetehcodez graphics gui helpwithhomework html ide image input integer j2me japplet java javaarraylist javaprojects jmf jni jpanel julia linux list loop map method methods mobile netbeans newbie number object objects oracle oriented os panel print problem program programming project projects recursion replaydirector reporting researchinmotion return robot rotatetext scanner screen se server set size sms socket sort sql stream string swing test threads time transfer tree ubuntu windows






