[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math


View post   

File: 5 KB, 194x157, Untitled.jpg [View same] [iqdb] [saucenao] [google]
1747175 No.1747175 [Reply] [Original]

I needz help. Can someone debug my celcius to Fahrenheit java program?

import java.util.Scanner;
public class Temp
{
public static void main( String[] args)
{
Scanner input = new Scanner(System.in);
String name;
System.out.println("What is the Cel temp you would like to convert to Fahrenheit?");
celcius = input.nextLine();
farhrenheit = (9/5) * celcius +32;
System.out.println(celcius + " is " + farhrenheit + "in farhrenheit");

}
}

>> No.1747185

What error does it give?

>> No.1747194
File: 8 KB, 189x200, 1273517845389.jpg [View same] [iqdb] [saucenao] [google]
1747194

>>1747175
this bullshit won't even compile, you didn't even declare celcius.
also you can't multiply by strings
also 9/5 = 1
tl;dr OP is a fag

>> No.1747196
File: 20 KB, 476x460, rounded_IDE_black_24.jpg [View same] [iqdb] [saucenao] [google]
1747196

1/10, your IDE would be screaming at you.

>> No.1747197

$5 says this is your first homework assignment/project for your Intro. to Java class

(Don't take that as an insult though. Everybody has to start somewhere)

>> No.1747202

1) tell us why you think your program needs to be debugged, reasons/errors
2) give us the full code
3) where was variable 'celcius' defined?
4) where is main() and init()?

>> No.1747217

I think you are looking for this:

http://download.oracle.com/javase/1.4.2/docs/api/java/text/NumberFormat.html

>> No.1747219

OP IS HERE.

YES FIRST INTRO TO JAVA CLASS I FOUND THE PROBLEM GUYZ. instead of input.nextLine it's input.nextDouble

import java.util.Scanner;
public class Temp
{
public static void main( String[] args)
{
Scanner input = new Scanner(System.in);

System.out.print("What is the Cel temp you would like to convert to Fahrenheit?");
double celcius = input.nextDouble();
double farhrenheit = (9/5) * (celcius +32);
System.out.println(celcius + " in celcius is " + farhrenheit + "in farhrenheit" );

}
}
HERE IT IS FIXED AND FUCK YOU THE PERSON WHO CALLED ME GAY.

BTW BLAME MY PROFESSOR HE THINKS THIS ISN'T INTRO TO JAVA FOR SOME REASON, HE THINKS WE ALREADY KNOW JAVA.. FML

>> No.1747221

>>1747217

NO!

This kid is screwed up already, let him learn to express data with standard data types first.

>> No.1747230
File: 100 KB, 800x1100, 1251693163534.jpg [View same] [iqdb] [saucenao] [google]
1747230

>java

fucking retard

>can't F<>C

fucking American

>> No.1747234

>>1747219
now test your fucking program
100 celsius should be 212 fahrenheit
it won't work

>> No.1747247

OP HERE... I ADDED A DECIMAL TO 9/5 MAKING IT 9/5.0

THANKS FOR ALL THE HELP YOU FUCKERS. I ALMOST HAD TO EMAIL ULILLILLIA.ಠ_ಠ

>> No.1747249
File: 52 KB, 500x1105, programmer_hierarchy[11].gif [View same] [iqdb] [saucenao] [google]
1747249

include <iostream>

int main(){
double x;
std::cout<<"What is the Cel temp you would like to convert to Fahrenheit? ";
std::cin>>x;
std::cout<<x<<" celcius is "<<(9/5)*x +32<<" in farhrenheit"<<endl;
}

>> No.1747256
File: 86 KB, 2560x1600, Trollface2.png [View same] [iqdb] [saucenao] [google]
1747256

>>1747247
you are still retarded
the correct formula would be (9./5) * celcius +32;

>> No.1747258
File: 3 KB, 209x215, 1278403236276.png [View same] [iqdb] [saucenao] [google]
1747258

>>1747249
>post a faggy picture
>his program has the same mistake as OP's

>> No.1747264

>>1747175
>OP uses java

lol faggot.

>> No.1747269

>>1747256

Give the equation 1.8, and watch as your compiler doesn't have to setup an extra processor division instruction for the fraction in the bytecode.

>> No.1747270
File: 183 KB, 566x690, 1280786169585.jpg [View same] [iqdb] [saucenao] [google]
1747270

I would say gbt >>>/prog/ but since it's in java: GTFO and GBT myspace/facebook/twitter or wherever else people without analytical skills/intelligence go!

>> No.1747276

>>1747269
>implying you can find a compiler that won't optimize it

>> No.1747278

>>1747249
>>1747249
>Ajax is higher than javascript

how the fuck does that work?

>> No.1747286

>>1747269
It would not make any difference. Compilers are smart enough do do these substitutions themselves.

>> No.1747297

you guys are assholes, Java is a good language for learning the fundamentals of OO programming and data structures. Shit, to learn data structures you don't even need a language, and you sure as fuck don't need to be worrying about segfaults and mem leaks

Everybody bitching about Java running slow already knows that that doesn't make any difference in trivial shit like OP's homework.

>> No.1747317

>It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.
- Edsger W. Dijkstra, 1975

>[...] The teaching of BASIC should be rated as a criminal offence: it mutilates the mind beyond recovery.
- Edsger W. Dijkstra, 1984

Now, in 2010, Java is the new Basic.

>> No.1747320

>>1747317
more like DICKstra amirite?

>> No.1747357

Alrighty faggots, listen, let me clear this shit up. Anyone who says with all seriousness that Java is slow is a cunt-faced idiot. Java stopped being slow a long time ago, but you guys must be too busy believing on father-to-son trolls. Ever heard of JIT?

Just kidding, Java is slow like hell. What a language full of liquid shit waiting to be sprayed on your face.

>> No.1747376

which language would you rather fuck
Java
or Objective-C
you have to choose one
show your work

>> No.1747382

>>1747357
Of course java is slow as hell. You can check the language benchmarks here.

http://shootout.alioth.debian.org/u32/which-programming-languages-are-fastest.php

Stuff that C++ programs do in 1.09 seconds take a whopping 1.36 seconds in slow ass java. Add the fact, that java does not have pointer arithmetics. How is one supposed to learn programming in such restrictive environment.