GIDForums  

Go Back   GIDForums > Computer Programming Forums > CPP / C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 02-Nov-2007, 17:18
sool87 sool87 is offline
New Member
 
Join Date: Nov 2007
Posts: 2
sool87 is on a distinguished road

I'm stuck in a problem.... plzzzzzz help


Hey, I have to do a homework and it's due for Sunday 04.11
I do them all but I'm stuck in only one.
I'm gonna write you the whole "programming exercise" in here.
( Write a program that converts a temperature from degrees Fahrenheit to degrees centigrade. The formula for converting the temperature from degrees Fahrenheit to degrees centigrade is
C = (5/9) (F - 32)
Your program should prompt the user to enter a temperature given in degrees Fahrenheit. The program should output the temperature both in degrees Fahrenheit and degrees centigrade.)
waitin for ur replies.
  #2  
Old 02-Nov-2007, 17:21
Algar Algar is offline
Junior Member
 
Join Date: Sep 2007
Posts: 92
Algar will become famous soon enough

Re: I'm stuck in a problem.... plzzzzzz help


Whats the problem ?

cin and cout for input and output to screen,

use double or float for most values so you don't lose accuracy
  #3  
Old 02-Nov-2007, 19:10
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,234
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all

Re: I'm stuck in a problem.... plzzzzzz help


Try reading the Guidelines, esp #1,2,5...
__________________

Cow: You're a lawyer too?
Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase!
  #4  
Old 02-Nov-2007, 19:29
doom1992 doom1992 is offline
Junior Member
 
Join Date: Jul 2007
Posts: 98
doom1992 is on a distinguished road

Re: I'm stuck in a problem.... plzzzzzz help


Well its you lucky day. I have this already made as i was also assigned it.

CPP / C++ / C Code:
#include <iostream>

int main () {
    const unsigned short ADD_SUBTRACT = 32;
    const float RATIO = 5.0/9.0;
    
    float tempratureIN, tempratureOut;
    char tempTypeIn, tempTypeOut;
    
    std::cout <<"Enter a temprature: [##.#] ";
    while (!(std::cin >> tempratureIN)) {
          std::cin.clear();
          std::cin.ignore(100, '\n');
          std::cout <<"Enter a valid temprature: [##.#] ";
          }
    
    std::cin.ignore(100, '\n');
    
    do {
        std::cout <<"Is this in degrees fahrenheit or Celsius? [F/C] ";
        std::cin >> tempTypeIn;
        std::cin.ignore(100, '\n');
        }
        
    while ((tempTypeIn != 'C')&&(tempTypeIn != 'c')&&(tempTypeIn != 'F')&&(tempTypeIn != 'f'));
    
    std::cout <<"\n";
    
    switch (tempTypeIn) {
           
           case 'C':
           case 'c':
                tempratureOut = (tempratureIN / RATIO) + ADD_SUBTRACT;
           
           tempTypeOut = 'F';
           tempTypeIn = 'C';
           
           break;
           
           case 'F':
           case 'f':
                tempratureOut = (tempratureIN - ADD_SUBTRACT) * RATIO;
                
           tempTypeIn = 'F';
           tempTypeOut = 'C';
           
           break;
           
           default:
                   tempTypeOut = 'E';
                   break;
                   }
    
    if (tempTypeOut != 'E') {
                    std::cout << tempratureIN << " Degrees " << tempTypeIn << " is equal to " << tempratureOut << " Degrees " << tempTypeOut << "\n\n";
                    }
    else {
         std::cout <<"The calculation could not be made duse to an invilad input.\n\n";
         }
         
         std::cout <<"Press Enter or Return to contiue.\n";
         std::cin.get();
         
         return 0;
         
}
  #5  
Old 02-Nov-2007, 21:15
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,234
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all

Re: I'm stuck in a problem.... plzzzzzz help


Oh boy! Another ready-made piece of code so the student doesn't have to know how to program! Good job!

__________________

Cow: You're a lawyer too?
Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase!
  #6  
Old 03-Nov-2007, 03:09
davis
 
Posts: n/a

Re: I'm stuck in a problem.... plzzzzzz help


Quote:
Originally Posted by WaltP
Oh boy! Another ready-made piece of code so the student doesn't have to know how to program! Good job!


But the beauty of it is that when OP presents doom's code, the "typos" will be a part of it!

duse to an invilad (due to an invalid)
contiue (continue)
temprature (temperature)
fahrenheit (when used as output to the user, should be capitalized)

...of course, all the OP had to do was search the forums for Fahrenheit and the code would have been found easily.

http://www.gidforums.com/t-9536.html


...besides, all of that "code" that doom posted seems rather like overkill to me considering the OP's assignment:

CPP / C++ / C Code:
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    cout << "Enter a temperature in degrees Fahrenheit: ";
    float f;
    cin >> f;
    cout << setiosflags( ios::fixed | ios::showpoint ) << setprecision( 3 );
    cout << f << " F = " << (5.0F/9.0F)*(f - 32) << " C" << endl;

    return 0;
}

Output:

Code:
Enter a temperature in degrees Fahrenheit: 100 100.000 F = 37.778 C Enter a temperature in degrees Fahrenheit: 212 212.000 F = 100.000 C Enter a temperature in degrees Fahrenheit: 32 32.000 F = 0.000 C Enter a temperature in degrees Fahrenheit: 0 0.000 F = -17.778 C Enter a temperature in degrees Fahrenheit: -123.45 -123.450 F = -86.361 C

...and, I don't think that it is such a bad thing to get someone going with a bit of example code that solves the problem. Sometimes newbies are stuck on the very basics and a bit of help will get them going.


:davis:
  #7  
Old 04-Nov-2007, 16:07
sool87 sool87 is offline
New Member
 
Join Date: Nov 2007
Posts: 2
sool87 is on a distinguished road

Re: I'm stuck in a problem.... plzzzzzz help


Quote:
Originally Posted by davis
But the beauty of it is that when OP presents doom's code, the "typos" will be a part of it!

duse to an invilad (due to an invalid)
contiue (continue)
temprature (temperature)
fahrenheit (when used as output to the user, should be capitalized)

...of course, all the OP had to do was search the forums for Fahrenheit and the code would have been found easily.

http://www.gidforums.com/t-9536.html


...besides, all of that "code" that doom posted seems rather like overkill to me considering the OP's assignment:

CPP / C++ / C Code:
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    cout << "Enter a temperature in degrees Fahrenheit: ";
    float f;
    cin >> f;
    cout << setiosflags( ios::fixed | ios::showpoint ) << setprecision( 3 );
    cout << f << " F = " << (5.0F/9.0F)*(f - 32) << " C" << endl;

    return 0;
}

Output:

Code:
Enter a temperature in degrees Fahrenheit: 100 100.000 F = 37.778 C Enter a temperature in degrees Fahrenheit: 212 212.000 F = 100.000 C Enter a temperature in degrees Fahrenheit: 32 32.000 F = 0.000 C Enter a temperature in degrees Fahrenheit: 0 0.000 F = -17.778 C Enter a temperature in degrees Fahrenheit: -123.45 -123.450 F = -86.361 C

...and, I don't think that it is such a bad thing to get someone going with a bit of example code that solves the problem. Sometimes newbies are stuck on the very basics and a bit of help will get them going.


:davis:


THANKS A LOT, u r such a brilliant
  #8  
Old 04-Nov-2007, 20:01
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,234
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all

Re: I'm stuck in a problem.... plzzzzzz help


Quote:
Originally Posted by davis
...and, I don't think that it is such a bad thing to get someone going with a bit of example code that solves the problem. Sometimes newbies are stuck on the very basics and a bit of help will get them going.
Possibly. But I'd bet anyone that actually asked for the answer or only posted the problem will turn in said code with their name on it. I cannot get excited about helping someone that much.
__________________

Cow: You're a lawyer too?
Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase!
  #9  
Old 05-Nov-2007, 04:16
davis
 
Posts: n/a

Re: I'm stuck in a problem.... plzzzzzz help


Quote:
Originally Posted by WaltP
Possibly. But I'd bet anyone that actually asked for the answer or only posted the problem will turn in said code with their name on it. I cannot get excited about helping someone that much.

...and you might win that bet. So what? Will your actions prevent ethics violations? Surely not.

Besides, the "promise of reuse" has been "fulfilled" in some obscure way in such cases!


:davis:
  #10  
Old 05-Nov-2007, 08:12
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,234
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all

Re: I'm stuck in a problem.... plzzzzzz help


Quote:
Originally Posted by davis
...and you might win that bet. So what? Will your actions prevent ethics violations? Surely not.
Of course it will. By only pointing the way and not giving them a complete program they cannot possibly hand it in with their name on it.
__________________

Cow: You're a lawyer too?
Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase!
 
 

Recent GIDBlogLast Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Graphic problem in Unreal Tournament 2004 zerox Computer Software Forum - Games 10 09-Oct-2005 12:31
Runtime Problem involving "printf" in C Program supamakia C Programming Language 2 09-Oct-2005 10:09
a significant problem after installing Xp mohammad Computer Software Forum - Windows 10 09-Aug-2005 07:03
commands out of sync problem (c++ builder) Largowww MS Visual C++ / MFC Forum 0 28-May-2005 03:40
Another FX 5600 problem (but with details that might shed light on this) BobDaDuck Computer Hardware Forum 2 16-Apr-2004 07:53

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 22:44.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.