Reviews comments and ideas would be appreciated.

Java Discuss, Reviews comments and ideas would be appreciated. at Programmers Lounge forum; import TerminalIO.KeyboardReader; public class Quotient{ public static void main(String [] args){ KeyboardReader reader = new KeyboardReader(); int num1; // number ...


Go Back   Gamerz Needs - For All Your Gaming Needs! > Technology Zone > Programmers Lounge > Java
Forgot Password? | Sign Up!

Notices

Advertisement
   

Closed Thread
 
Bookmark this Thread Tools Display Modes
  #1  
Old 01-14-2008, 09:09 PM
hogworth's Avatar
Double Wood Axe
 
Last Online: 06-01-2008 12:03 PM
Join Date: Oct 2007
Location: Canada, Toronto.
Age: 19
Posts: 17
Thanks: 1
Thanked 1 Time in 1 Post
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Latest Blog:
Rep Power: 0
hogworth is on a distinguished road
Points: 315.00
Bank: 0.00
Total Points: 315.00
Reviews comments and ideas would be appreciated.

import TerminalIO.KeyboardReader;

public class Quotient{
public static void main(String [] args){
KeyboardReader reader = new KeyboardReader();
int num1; // number 1
int num2; // number 2
int ans; // answer
int rem; // remainder

System.out.println("Please enter the first number: ");
num1 = reader.readInt;
System.out.println("Please enter the second number: ");
num2 = reader.readInt;

if(num1>num2){ // Compare the numbers to find the larger.
ans=num1/num2; // divide the larger to find quotient.
rem=num1%num2; // divide the larger via modulus to find remainder.
System.out.println(ans+"r. "+rem);
}

else{ // If num1 < num2.
ans=num2/num1;
rem=num2%num1;
System.out.println(ans+"r. "+rem);
}
}
}



DOing this stuff for school in notepad to lazy to install jdk and jvm and yadda yadda so if it works, or could use some doctoring much appreciated, I have a couple more I want to post.
-----------------This post was merged together. In future use the edit button.-----------------

import TerminalIO.KeyboardReader;

public class RightTriangle{
public static void main(String [] args){
KeyboardReader reader = new KeyboardReader();

int side1;
int side2;
int side3;

double total1;
double total2;
double total3;

System.out.println("Enter a side: "); //
side1 = reader.readInt; // read in side1
System.out.println("Enter second side: "); //
side2 = reader.readInt; // read in side2
System.out.println("Enter third side: "); //
side3 = reader.readInt; // read in side3

if(side1>side2){ // if side 1 is largest

if(side1>side3){
total1=Math.pow(side2,2)+Math.pow(side3,2);

if(total1==Math.pow(side1,2)){
System.out.println("This is a right triangle"); // as it satisfies Pythagoreum.
}
else{
System.out.println("This is NOT a right triangle");
}
}
}

if(side2>side3){ // if side 2 is largest

if(side2>side1){
total2=Math.pow(side1,2)+Math.pow(side3,2);

if(total2==Math.pow(side2,2)){
System.out.println("This is a right triangle"); // as it satisfies Pythagoreum.
}
else{
System.out.println("This is NOT a right triangle");
}
}
}

if(side3>side2){ // if side 3 is largest

if(side3>side1){
total3=Math.pow(side2,2)+Math.pow(side1,2);

if(total3==Math.pow(side3,2)){
System.out.println("This is a right triangle"); // as it satisfies Pythagoreum.
}
else{
System.out.println("This is NOT a right triangle");
}
}
}
}
}

Last edited by hogworth; 01-14-2008 at 09:11 PM. Reason: Automerged Doublepost
  #2  
Old 01-14-2008, 09:12 PM
Kohaku's Avatar
killah4evas slave
 
Last Online: Today 12:49 PM
Join Date: Nov 2006
Location: 我在你心裏
Age: 18
Posts: 5,988
Donation Award 
Blog Entries: 1
Thanks: 23
Thanked 762 Times in 530 Posts
Nominated 1 Time in 1 Post
TOTW/F/M Award(s): 0
Latest Blog: AP Calculus Exam
Rep Power: 26
Kohaku is a jewel in the roughKohaku is a jewel in the roughKohaku is a jewel in the rough
Points: 16,710.37
Bank: 6,125,393.08
Total Points: 6,142,103.45
Pubic Hair Trimming MasterShip - AznMonky drugged apple *cough*urine*cough* juice - Ken Get Fat You Naughty Pubic Hair You - AznMonky Start sucking and get ready for me babes ;) - AznMonky For not being a retard :) - Slugsnack 
Marked as kashin's property - kashin You need it. - Purple_Haze you have been banned by user ROVE - ROVE merry christmas to all !! - Kojack510 For being the only good staff member. - Purple_Haze 
gotcha RPKMHFTAGUITALABPC - ROVE LOL, for moderating the same post I was moderating at the same time - XD - Spiro Because you're awesome to chat with. - Purple_Haze x33 - Purple_Haze 
Green - lifestyles Burgundy - YarD Lavender - Alterna X 
Send a message via AIM to Kohaku Send a message via MSN to Kohaku Send a message via Yahoo to Kohaku
Ah I remember learning this in Java class last year. The AP test was HELLA hard.
__________________






Only by letting strangers in can we find new ways to be ourselves..-Yoshiya Kiryu, TWEWY
Favorite Animes: Inuyasha, Kanon 2006, Elfen Lied, Chobits, Higurashi no Naku Koro Ni/Kai, AIR
Rozen Maiden/Traumend, Clannad, Claymore, Welcome to NHK
Currently Watching: Fate Stay Night, Full Metal Panic

Tom, a respected staff, you will be missed...but never forgotten. R.I.P. 1990-2007
You will always be our GzN Cancer..and my personal green monster. ^_^
Don't worry, we will play kartrider soon.
  #3  
Old 01-14-2008, 09:32 PM
hogworth's Avatar
Double Wood Axe
 
Last Online: 06-01-2008 12:03 PM
Join Date: Oct 2007
Location: Canada, Toronto.
Age: 19
Posts: 17
Thanks: 1
Thanked 1 Time in 1 Post
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Latest Blog:
Rep Power: 0
hogworth is on a distinguished road
Points: 315.00
Bank: 0.00
Total Points: 315.00
Yeah I havn't done anything all year so I expect 2 weeks of severe work will pass me.

I could use some help from someone here.
HERes The badly worded question
A Prime number is an interger greater than 1 divisible by only itself and 1. The first seven prime numbers are 2,3,5,7,11, 13 and 17. Write a program that takes in a number from the user and prints out whether their number is prime or not.

I think I've got the math down its the syntax that getting to me, I think I can use an If loop

if (i%==0)
exit loop
else
x=x-1

I'm not asking you write the code for me but getting me started would help, I'm dying here and it would be much appreciated.
  #4  
Old 01-14-2008, 10:05 PM
Kohaku's Avatar
killah4evas slave
 
Last Online: Today 12:49 PM
Join Date: Nov 2006
Location: 我在你心裏
Age: 18
Posts: 5,988
Blog Entries: 1
Thanks: 23
Thanked 762 Times in 530 Posts
Nominated 1 Time in 1 Post
TOTW/F/M Award(s): 0
Latest Blog: AP Calculus Exam
Rep Power: 26
Kohaku is a jewel in the roughKohaku is a jewel in the roughKohaku is a jewel in the rough
Points: 16,710.37
Bank: 6,125,393.08
Total Points: 6,142,103.45
Pubic Hair Trimming MasterShip - AznMonky drugged apple *cough*urine*cough* juice - Ken Get Fat You Naughty Pubic Hair You - AznMonky Start sucking and get ready for me babes ;) - AznMonky For not being a retard :) - Slugsnack 
Marked as kashin's property - kashin You need it. - Purple_Haze you have been banned by user ROVE - ROVE merry christmas to all !! - Kojack510 For being the only good staff member. - Purple_Haze 
gotcha RPKMHFTAGUITALABPC - ROVE LOL, for moderating the same post I was moderating at the same time - XD - Spiro Because you're awesome to chat with. - Purple_Haze x33 - Purple_Haze 
Green - lifestyles Burgundy - YarD Lavender - Alterna X 
Send a message via AIM to Kohaku Send a message via MSN to Kohaku Send a message via Yahoo to Kohaku
Here's my source code:

public class Prime
{

public static void main(String[]args)
{


EasyReader IO = new EasyReader();
System.out.print("Enter a number: ");
int num= IO.readInt();
if (num%2==1)
{

System.out.println("The number " + num + " is prime.");
}
else
System.out.println("The number " + num + " is not prime");

}
}

~~~~~~~~~~~
__________________






Only by letting strangers in can we find new ways to be ourselves..-Yoshiya Kiryu, TWEWY
Favorite Animes: Inuyasha, Kanon 2006, Elfen Lied, Chobits, Higurashi no Naku Koro Ni/Kai, AIR
Rozen Maiden/Traumend, Clannad, Claymore, Welcome to NHK
Currently Watching: Fate Stay Night, Full Metal Panic

Tom, a respected staff, you will be missed...but never forgotten. R.I.P. 1990-2007
You will always be our GzN Cancer..and my personal green monster. ^_^
Don't worry, we will play kartrider soon.
The Following User Says Thank You to Kohaku For This Useful Post:
hogworth (01-14-2008)
  #5  
Old 01-14-2008, 10:33 PM
hogworth's Avatar
Double Wood Axe
 
Last Online: 06-01-2008 12:03 PM
Join Date: Oct 2007
Location: Canada, Toronto.
Age: 19
Posts: 17
Thanks: 1
Thanked 1 Time in 1 Post
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Latest Blog:
Rep Power: 0
hogworth is on a distinguished road
Points: 315.00
Bank: 0.00
Total Points: 315.00
Ok, Forgive me if I ask something stupid or beat a dead horse but I'm just trying to understand your code, it looks pretty straight forward but I dunno what easy reader is.
-------------------------------------------------
I can just go through the whole
import TerminalIO.KeyboardReader
KeyboardReader reader = new KeyboardReader();

int(or double?) x; // number 1
to bypass this I don't want elegant code I need straightforward gets the job done.
EasyReader IO = new EasyReader();


System.out.print("Enter a number: ");
int num= IO.readInt();
-----------------------------------------------------

if (num%2==1)
{

the input number is divided by two modulus, and if the remainder is 1 then the number is Prime, but does this simple thing really work with all numbers?

-----------------------------------------------------
System.out.println("The number " + num + " is prime.");
}
else
System.out.println("The number " + num + " is not prime");

}
}


Again Thank you.
  #6  
Old 01-14-2008, 10:52 PM
Kohaku's Avatar
killah4evas slave
 
Last Online: Today 12:49 PM
Join Date: Nov 2006
Location: 我在你心裏
Age: 18
Posts: 5,988
Blog Entries: 1
Thanks: 23
Thanked 762 Times in 530 Posts
Nominated 1 Time in 1 Post
TOTW/F/M Award(s): 0
Latest Blog: AP Calculus Exam
Rep Power: 26
Kohaku is a jewel in the roughKohaku is a jewel in the roughKohaku is a jewel in the rough
Points: 16,710.37
Bank: 6,125,393.08
Total Points: 6,142,103.45
Pubic Hair Trimming MasterShip - AznMonky drugged apple *cough*urine*cough* juice - Ken Get Fat You Naughty Pubic Hair You - AznMonky Start sucking and get ready for me babes ;) - AznMonky For not being a retard :) - Slugsnack 
Marked as kashin's property - kashin You need it. - Purple_Haze you have been banned by user ROVE - ROVE merry christmas to all !! - Kojack510 For being the only good staff member. - Purple_Haze 
gotcha RPKMHFTAGUITALABPC - ROVE LOL, for moderating the same post I was moderating at the same time - XD - Spiro Because you're awesome to chat with. - Purple_Haze x33 - Purple_Haze 
Green - lifestyles Burgundy - YarD Lavender - Alterna X 
Send a message via AIM to Kohaku Send a message via MSN to Kohaku Send a message via Yahoo to Kohaku
EasyReader is just an code for imputing numbers and/or words. Google EasyReader and the .java file should be the first thing that pops up. It makes imputing so much easier. You don't need the import TerminalIO at the top. For the number, using int instead of double is fine since you use whole numbers anyway. And yes, this code should work since I compiled it and tested myself. Give it a shot.
__________________






Only by letting strangers in can we find new ways to be ourselves..-Yoshiya Kiryu, TWEWY
Favorite Animes: Inuyasha, Kanon 2006, Elfen Lied, Chobits, Higurashi no Naku Koro Ni/Kai, AIR
Rozen Maiden/Traumend, Clannad, Claymore, Welcome to NHK
Currently Watching: Fate Stay Night, Full Metal Panic

Tom, a respected staff, you will be missed...but never forgotten. R.I.P. 1990-2007
You will always be our GzN Cancer..and my personal green monster. ^_^
Don't worry, we will play kartrider soon.
  #7  
Old 01-14-2008, 10:59 PM
hogworth's Avatar
Double Wood Axe
 
Last Online: 06-01-2008 12:03 PM
Join Date: Oct 2007
Location: Canada, Toronto.
Age: 19
Posts: 17
Thanks: 1
Thanked 1 Time in 1 Post
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Latest Blog:
Rep Power: 0
hogworth is on a distinguished road
Points: 315.00
Bank: 0.00
Total Points: 315.00
Awesome thanks alot.
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Advertisement
   


Main Navigation
Home
GzN Forums
GzN Games
GzN News
Top Games
GzN Cheats
GzN Articles
GzN Reviews
GzN Downloads
User Control Panel
Advertising
RSS Feed
2Moons
Adventure Quest
AirRivals
America's Army
Anarchy Online
Archlord
Audition
Battlefield Series
Cabal Online
Call Of Duty Series
Combat Arms
Conquer Online
Counter Strike
Day of Defeat
Deicide Online
Diablo Series
Doom Series
Drift City
Enemy Territory
Eudemons Online
Final Fantasy
Flyff (Fly For Fun)
FreeStyle Street Basketball
General Game Discussion
Ghost Online
Granado Espada
Grand Theft Auto Series
Guild Wars
Gunbound
Gunz Online
Habbo Hotel
Half-Life 2
Hero Online
KartRider
Knights Online
Maple Story
Medal of Honor
MU Online
Neopets
Pangya
Quake Series
Ragnarok Online
Rakion
Red Orchestra
Rose Online
Runescape
Scions of Fate
Silkroad Online
Sims Series
Soldier Front
Starcraft
Tales of Pirates
Tibia
The Ship
Trickster Online
TS Online
Unreal Tournament
War Rock
WolfTeam
World of Warcraft & Series
Affiliates
COD4 Hacks
BF2 Hacks


All times are GMT -8. The time now is 04:04 PM.