View Full Version : Help me with my Java Hw!
you guys are my last resort i have this project due by 9:15 am tommm and i cant figure out how to do it...its pissing the shit outta me here check it out if anyone knows it please help me, it would be greatly apreciated
this is the project
Fahrenheit to Celsius / Celsius to Fahrenheit Project
Structured Programming
This project asks you to make a simple temperature converter. You will need to write two methods in addition to the main method. Your methods should be defined in a class called FCConverter (remember, spelling and capitalization matters!)
public static double cToF(double degrees)
public static double fToC(double degrees)
Both methods should convert the parameter degrees to the desired units and return the result. In your main method, prompt the user for a temperature as well as the type. Then the temperature in its converted form should be printed out. The program should then simply exit. You should reprimand the user if they type in a type of temperature unit that the program does not understand, but your program should still just exit.
this is my code
public class FCConverter
{
public static double cToF(double degrees)
{
degrees = (9/5)*degrees+32;
return degrees;
}
public static double fToC(double degrees)
{
degrees = (5/9)*(degrees-32);
return degrees;
}
public static void main(String[] args)
{
System.out.println("+++++Welcome to Vlads Temperature Converter+++++");
System.out.println(" ");
System.out.println(" What would you like to do?");
System.out.println(" ");
System.out.println(" [A] Change Celcius to Fahrenheit");
System.out.println(" [B] Change Fahrenheit to Celius");
System.out.println(" Choice [A/B/]: ");
char userInput = Keyboard.readChar();
System.out.println("User's input is :"+userInput);
if (userInput == 'a' || userInput == 'A')
{
System.out.println("Enter your first number:");
double degrees = Keyboard.readDouble ();
}
else if (userInput == 'b' || userInput == 'b')
{
System.out.println("Enter your first number:");
double degrees = Keyboard.readDouble ();
}
return;
public static double cToF(double degrees)
{
degrees = (9/5)*degrees+32;
return degrees;
}
public static double fToC(double degrees)
{
degrees = (5/9)*(degrees-32);
return degrees;
}
}
}
Keyboard.readChar and double is a keyboard file that will read the users imput please help me outt peeps
Kreator
10-25-2004, 08:02 AM
Know this is prolly late, but anyways.
has been a while since i had to deal with java, but.... what's the problem with the code?
public class FCConverter
{
public static double cToF(double degrees)
{
degrees = (9/5)*degrees+32;
return degrees;
}
public static double fToC(double degrees)
{
degrees = (5/9)*(degrees-32);
return degrees;
}
public static void main(String[] args)
{
System.out.println("+++++Welcome to Vlads Temperature Converter+++++");
System.out.println(" ");
System.out.println(" What would you like to do?");
System.out.println(" ");
System.out.println(" [A] Change Celcius to Fahrenheit");
System.out.println(" [B] Change Fahrenheit to Celius");
System.out.println(" Choice [A/B/]: ");
char userInput = Keyboard.readChar();
System.out.println("User's input is :"+userInput);
System.out.println("Enter your first number:");
double degrees = Keyboard.readDouble ();
System.out.print("Conversion result: ");
if (userInput == 'a' || userInput == 'A')
{
System.out.println("" + cToF(degrees)); //not sure, but iirc println doesnt like non string parameters
}
else if (userInput == 'b' || userInput == 'b')
{
System.out.println("" + fToC(degrees));
}
else{
System.out.println("Invalid entry. Exiting.");
}
System.exit(0);
}
Thats how id write it. Don't have any java compiler/interpreter here, so if there any problems with this code, pm me.
RedlineRacer
10-25-2004, 08:20 AM
You don't have any import statements. You need to import something like TerminalIO to use that keyboard reader. Also, what were the errors you were getting?
its ok guys i didnt define how to link to my method and i had one extra braces sumewhere that f*ked everyhting up thx for your help thought i got an a on it :)
steaLthy240
10-25-2004, 08:01 PM
damn i wish i had easy hw like that..im writing game playing algorithms for CPU AI... :hs:
tsunami0ne
10-26-2004, 02:43 PM
damn i wish i had easy hw like that..im writing game playing algorithms for CPU AI... :hs:
pft, u mean minimax search trees with alpha beta pruning? easy stuff :o
steaLthy240
10-26-2004, 07:37 PM
yup exactly..its hard for a 2nd year college student... :fawkd: probably easy for you though.. :cry:
MakotoS13
10-26-2004, 08:09 PM
see, your gamma flux capacitor is all wrong. ya gotta rotate the matrix assembly so that it's perpendicular to the solar heatsink cause if ya don't the dimeansional proportion will be all whacked out and mister kawisaki will make you perform hara-kari.
tsunami0ne
10-26-2004, 11:54 PM
yup exactly..its hard for a 2nd year college student... :fawkd: probably easy for you though.. :cry:
heheh, well it wasn't that easy, considering that my Othello AI got pwned by my fellow classmates.
Oh, and here's my advice to you: if your college is pushing Java as its standard programming language, take the time to learn C++ if you haven't already. I've heard that a bunch of colleges and universities are sort of... trying to get away from C++ by assigning a bunch of homework using Java... C++ should be your primary programming language if you hope to land a decent programming job. *shudder*
steaLthy240
10-27-2004, 03:40 AM
heheh, well it wasn't that easy, considering that my Othello AI got pwned by my fellow classmates.
Oh, and here's my advice to you: if your college is pushing Java as its standard programming language, take the time to learn C++ if you haven't already. I've heard that a bunch of colleges and universities are sort of... trying to get away from C++ by assigning a bunch of homework using Java... C++ should be your primary programming language if you hope to land a decent programming job. *shudder*
lol exactly..i originally started out learning C++ in hs, then I had to start learning Java when i came to college because it was a more "friendly" language. I never understood why they pushed Java when C++ seemed easier to me and when most jobs require it :ghey: ...although I'm not going to be a programmer so :gives:
and makoto...absolutely :bowrofl: i understood that completely..haha
Kreator
10-27-2004, 06:34 AM
nobody gives jack shit about c++ anymore, if anything its VC++, or rather .NET now. But it's not what language you code in, it's what you code and how good you are at it :) If you know how to think, you will be able to learn any language in a matter of days. C is faster then most languages, but HD & RAM speeds are so far behind hte CPU speeds that it doesn't matter what language you code in.
Colleges made their beginning courses in java because its easier to understand then C for people who are doing it for the first time. Its a two sided coin though.
mjjstang
10-27-2004, 11:48 AM
yah seriously makotos post probably made more sense than these others, but I remember having my dad buy me the c++.net program and I used it fora day and gave up, tried to teach myself. way too hard.
The setup should be the same as the Menu project, with the menu showing over and over again (until told to quit). The menu would show presedential candidates (Bush, Kerry, Nader, others if you want to put in the Libertarian party candidate or the Green party candidate), and then give the user a chance to pick a candidate. We'll assume that the voters aren't going to be committing voter fraud... but our program will!
You goal is to write a voting program that appears to work if you look at the code, but it actually mangles the results and either gives you results that don't add up right, one side gets more votes than it should, etc. The key is that the error should not be obvious and that there is a definite error that will effect the voting situation.
Code the works, or where the error is blatant, will not be considered.
The project needs to be handed in electronically by the first of Novemeber so our program could be implemented across the country by the election (the next day).
You need to turn in one java file (VoteCount.java). It will be totally up to my discretion who wins, and also the extent of prizes awarded.
anyoen wannna help me
MakotoS13
10-31-2004, 08:56 AM
i'm totally stickin with my origional hypothesis.
RedlineRacer
10-31-2004, 10:16 PM
nobody gives jack shit about c++ anymore, if anything its VC++, or rather .NET now. But it's not what language you code in, it's what you code and how good you are at it :) If you know how to think, you will be able to learn any language in a matter of days. C is faster then most languages, but HD & RAM speeds are so far behind hte CPU speeds that it doesn't matter what language you code in.
Colleges made their beginning courses in java because its easier to understand then C for people who are doing it for the first time. Its a two sided coin though.
Actually, the main thing with programming is making your code clean and professional. Thats what gets you a good job. Any dipshit can learn the code, but its harder to make it clean and easy to read.
tsunami0ne
10-31-2004, 11:12 PM
The setup should be the same as the Menu project, with the menu showing over and over again (until told to quit). The menu would show presedential candidates (Bush, Kerry, Nader, others if you want to put in the Libertarian party candidate or the Green party candidate), and then give the user a chance to pick a candidate. We'll assume that the voters aren't going to be committing voter fraud... but our program will!
You goal is to write a voting program that appears to work if you look at the code, but it actually mangles the results and either gives you results that don't add up right, one side gets more votes than it should, etc. The key is that the error should not be obvious and that there is a definite error that will effect the voting situation.
Code the works, or where the error is blatant, will not be considered.
The project needs to be handed in electronically by the first of Novemeber so our program could be implemented across the country by the election (the next day).
You need to turn in one java file (VoteCount.java). It will be totally up to my discretion who wins, and also the extent of prizes awarded.
anyoen wannna help me
you'll learn more by doing it yourself and struggling with it. i've noticed that most people that constantly ask for programming help are the ones that end up changing majors.
crioten
11-01-2004, 12:04 AM
hmmm, i keep getting a cannot find symbol when i try to just do a simple out put, anyone know what im doing wrong?
its been a while since ive messed with jcreator...
crioten
11-01-2004, 01:34 AM
maybe i did something wrong installing jcreator, but here are the error messages i get when i compile the project without doing anything to it:
C:\Program Files\Xinox Software\JCreatorV3 LE\MyProjects\haha\FCConverter\hello\src\Hello.jav a:11: cannot find symbol
symbol : class HelloFrame
location: class Hello
HelloFrame frame = new HelloFrame();
^
C:\Program Files\Xinox Software\JCreatorV3 LE\MyProjects\haha\FCConverter\hello\src\Hello.jav a:11: cannot find symbol
symbol : class HelloFrame
location: class Hello
HelloFrame frame = new HelloFrame();
^
2 errors
Process completed.
anyone have any idea as to what it may be?
steaLthy240
11-01-2004, 02:26 AM
you're trying to call a class inside of a class?
Kreator
11-01-2004, 08:34 AM
Actually, the main thing with programming is making your code clean and professional. Thats what gets you a good job. Any dipshit can learn the code, but its harder to make it clean and easy to read.
in big beuarocratic companies (read: government), thats exactly what they want you to do. They also like it when u write 8 page reports on every 20 lines of code you write, and make you sit at useless meetings for 4 hours on fridays.
Well, fuck beuarocracy. :madfawk:
As much as i like making money, if it's not challenging for me - i won't be doing it. And i don't give a shit if my tabs don't align or my variable names dont follow a conventional format. My thoughts are usually a bit further ahead then my hands and i can't always follow what i'm typing. As long as it is solid and fast code, i dont care what it looks like. You as an end user, won't see that anyway, so sue me.
Nothing is as important in programming as thinking. You can make you code as pretty as anyone, but if the code is worth shit, so are you. If you can write something twice as fast as the guy next to you, you are going to get the job no matter what your code looks like. You know those project leaders that make $250K a year? They don't write anything whatsoever. Their job is to design the algorithm and take care of every possible situation BEFORE a single line of code is written, so that there were no flaws in the original design. Thats why they make so much money. Because they can think. Working in a company of 4 programmers and 0 project leaders and being an enexperienced programming noob that i am doing projects complete from top to bottom in a timeframe that requires 10 people to do it in a government agency, i run into problems of forgetting something all the time. But hell, at least noone is sitting on my back asking for those "progress reports" and scolding me for every time my variable name doesnt reflect its meaning.
crioten: it cant find the helloframe class. Does it exist? is it in the same folder as the running program? is the file name for helloframe the same as the class name?
vBulletin® v3.8.11, Copyright ©2000-2021, vBulletin Solutions Inc.