473,396 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

can somebody fix my simple program

1
i have a simple program im making with basic knowledge of java

its supposed to prompt for a celsius temperature
do the calculation to convert it to fahrenhiet
then pop up saying the result


this is what i have its telling me line 8 has incompatible types

import javax.swing.*;

public class TemperatureConverter {
public static void main(String[]args) {
String str1 = JOptionPane.showInputDialog("Enter Temperature in Celsius");
double num1 = Double.parseDouble(str1);
double num2 = 1.8*num1+32;
String str2 = JOptionPane.showMessageDialog(null,"The Temperature in Fahrenheit is" + num2 );
}
}



HELP
Sep 28 '06 #1
1 1560
r035198x
13,262 8TB
i have a simple program im making with basic knowledge of java

its supposed to prompt for a celsius temperature
do the calculation to convert it to fahrenhiet
then pop up saying the result


this is what i have its telling me line 8 has incompatible types

import javax.swing.*;

public class TemperatureConverter {
public static void main(String[]args) {
String str1 = JOptionPane.showInputDialog("Enter Temperature in Celsius");
double num1 = Double.parseDouble(str1);
double num2 = 1.8*num1+32;
String str2 = JOptionPane.showMessageDialog(null,"The Temperature in Fahrenheit is" + num2 );
}
}



HELP
Expand|Select|Wrap|Line Numbers
  1. String str2 = JOptionPane.showMessageDialog(null,"The Temperature in Fahrenheit is" + num2 );
should be

Expand|Select|Wrap|Line Numbers
  1. JOptionPane.showMessageDialog(null,"The Temperature in Fahrenheit is" + num2 );
The method does not return anything and you do not need the String str2 anyway
Sep 28 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: John | last post by:
I am new to c++ programming and i just want to make a program that takes a users name, then converts it to a hex string, then puts it together in a fixed order. An example output would be: ...
17
by: savesdeday | last post by:
In my beginnning computer science class we were asked to translate a simple interest problem. We are expected to write an algorithm that gets values for the starting account balance B, annual...
11
by: JKop | last post by:
Take the following simple function: unsigned long Plus5Percent(unsigned long input) { return ( input + input / 20 ); } Do yous ever consider the possibly more efficent:
11
by: yangsuli | last post by:
i want to creat a link when somebody click the link the php script calls a function,then display itself :) i have tried <a href=<? funtion(); echo=$_server ?>text</a> but it will call the...
1
by: idsh | last post by:
I cant make this code work. I am new at Python, and in this program I have made a simple mastermind program. After creating the widgets, I try to insert text in the textbox in a function but all I...
30
by: galiorenye | last post by:
Hi, Given this code: A** ppA = new A*; A *pA = NULL; for(int i = 0; i < 10; ++i) { pA = ppA; //do something with pA
6
by: fido19 | last post by:
Once upon a time, there lived a chimpanzee called Luycha Bandor (aka Playboy Chimp). Luycha was unhappily married to Bunty Mona, a short but cute little lady chimp. Luycha was tall and handsome –...
1
by: astrogirl77 | last post by:
I'm new to C++ and am hoping to find help with coding a simple C program, am wanting to obtain code and functioning exe's. I code in an old version of Visual Basic 4.0, I have a simple app that...
9
by: ahilar12 | last post by:
1. <head> 2. <script type="text/javascript"> 3. </script> 4. </head> 5. <body> 6. <form> 7. <select name="team" id="mylist" > 8. <option></option> 9....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.