473,837 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert temperatures in fahrenheit to celsius

7 New Member
Ok i need to create a java program that repeatedly read temperatures in Fahrenheit and convert them to Celsius until a temperature > 212 F (the boiling point of water) is entered.

My program is:
Expand|Select|Wrap|Line Numbers
  1. import java.util.*;
  2. // Converter.java
  3. public class Converter
  4. {
  5.     public static void main(String[] args)
  6.     {
  7.         Scanner sc = new Scanner(System.in);
  8.         System.out.print("Enter temp: ");
  9.         int temp = sc.nextInt();
  10.         System.out.println(convertToC(temp));
  11.     }
  12.          public static int convertToC(int temp)
  13.     {
  14.         return ((temp - 32 ) * 5/9);
  15.     }
  16. }                
  17.  
I would really appreaciate it. Thank you. <email removed>
Nov 14 '08 #1
11 23251
JosAH
11,448 Recognized Expert MVP
What is your question?

kind regards,

Jos

ps. use those [ code ] tags for readability reasons next time when you post code.
Nov 14 '08 #2
mbnumba14
7 New Member
What is your question?

kind regards,

Jos

ps. use those [ code ] tags for readability reasons next time when you post code.

umm. my question is using the program that I have already posted, can you please modify that program so that it could read temperatures in Fahrenheit and convert them to Celsius until a temperature > 212 F (the boiling point of water) is entered. Thank you very much for replying. Sorry about the code tags.
Nov 14 '08 #3
JosAH
11,448 Recognized Expert MVP
umm. my question is using the program that I have already posted, can you please modify that program so that it could read temperatures in Fahrenheit and convert them to Celsius until a temperature > 212 F (the boiling point of water) is entered. Thank you very much for replying. Sorry about the code tags.
And what does your program do? Note that integer division does not do what
people expect it to do.

kind regards,

Jos
Nov 14 '08 #4
mbnumba14
7 New Member
ohh sorry, right now after a user inputs a number, the program outputs it in degrees Celcius.
Nov 14 '08 #5
JosAH
11,448 Recognized Expert MVP
ohh sorry, right now after a user inputs a number, the program outputs it in degrees Celcius.
Craft a liitle loop then and a small method that asks the user to enter a number
in Fahrenheit degrees:

Expand|Select|Wrap|Line Numbers
  1. for (int f= getFahrenheit(); f <= 212; f= getFahrenheit())
  2.    System.out.println(f+"F = "+convertToC(f)+"C");
  3.  
The convertToC() method converts Fahrenheit (its parameter) to Celcius.
You already have that method.

kind regards,

Jos
Nov 14 '08 #6
mbnumba14
7 New Member
yeah I know ,but ok. Maybe it would be easier for you to understand my question if it is wrote out like this:



"Modify your main function in the Converter class to repeatedly read temperatures in Fahrenheit and convert them to Celsius until a temperature > 212 F (the boiling point of water) is entered."

Sorry about the confusion
Nov 14 '08 #7
JosAH
11,448 Recognized Expert MVP
yeah I know ,but ok. Maybe it would be easier for you to understand my question if it is wrote out like this:



"Modify your main function in the Converter class to repeatedly read temperatures in Fahrenheit and convert them to Celsius until a temperature > 212 F (the boiling point of water) is entered."

Sorry about the confusion
But I just told you how to do that ...

kind regards,

Jos
Nov 14 '08 #8
mbnumba14
7 New Member
oh, now I see it sorry about that. Not to sound stupid but, where would I insert that part you gave me at.
Nov 14 '08 #9
mbnumba14
7 New Member
wow thanks alot for the help. I really needed it. Thanks again
Nov 14 '08 #10

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

Similar topics

19
7303
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below. Specifically, I have a problem with this portion in the WHERE clause: DATEADD(Day,tblMyEventTableName.ReminderDays, @DateNow) Between CONVERT(smalldatetime,str(DATEPART(Month, @DateNow)+1) + '/' + str(DATEPART(Day, tblMyEventTableName.TaskDateTime)) + '/'...
1
1787
by: Logan X via .NET 247 | last post by:
It's official....Convert blows. I ran a number of tests converting a double to an integer usingboth Convert & CType. I *ASSUMED* that CType would piggy-back ontop of Convert, and that performance would be identical. I was 100% incorrect. The code below produces the results: CType Took: 0.2187528 seconds. Convert Took: 12.187656 seconds.
4
3642
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is of the type the object is instantiated with. In my test program I have Option<std::string> and Option<long>. Here's the code for OptionBase and Option along with a small helper function. In the code are comments describing my problem, look closely...
5
6029
by: sjsn | last post by:
Basic C++, just started this course in school... So I'm very limited. What I'm at doing is, below I have a variable named inputTemp, which is the product of a char, F = Fahrenheit, C = Celsius and K = Kelvin... I want to be specific when asking the user for more information, such as degrees. So when I ask for degrees in F... it wont sound so kinda funny. I know I can write "Enter unit of temp that you want converted using (F)ahrenheit,...
2
2709
by: lifeshortlivitup | last post by:
I am a java beginner and am trying to tackle a temperature conversion problem but I don't exactly know how to begin. The problem asks that I write a program that allows the user to conver either from degrees Celsius to Fahrenheit or from degrees Fahrenheit to Celsius. I have the following formulas to accomplish this already: degreesC = 5(degreesF - 32)/9 degreesF = (9(degreesC)/5)+32 Then it asks to prompt the use to enter a temperature...
1
3606
by: johnlim20088 | last post by:
Hi, Currently I have 6 web projects located in Visual Source Safe 6.0, as usual, everytime I will open solution file located in my local computer, connected to source safe, then check out/check in some files and work on it. Let say, I want add new page to web project named websiteOrder.sln, i will open websiteOrder.sln in my local computer, connected to websiteOrder.sln located in Visual Source Safe 6.0(source safe located in another...
4
3627
by: kipj77 | last post by:
Hi i was wondering why the hell this program isn't working for me, I am in a 100 level computer science class and need help. This program is supposed to take in data of degrees Fahrenheit and spit out what it is in Celsius, anyway here it is and tell me if there is anything wrong: #include <iostream> using namespace std; int main() { double temperatureF;
0
10795
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not a new concept, there is a concept called Steganography which enables to conceal your secret...
0
9847
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10899
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10583
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10280
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7824
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5680
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4481
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4058
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3128
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.