0

hello friends i need help about the "Extension" part pls help me..

a menu driven c++ program using case/switch that gives the user the following options:

A. Fahrenheit to Celsius Converter
B. Celsius to Fahrenheit Converter
C. Inches to Feet converter
D. Feet to Inches Converter

The program should work if the user enters either capital or lower-case letters. All numbers should be rounded to two decimal places. Any choice not on the menu should give an error message.

Code: ( cpp )

#include<iostream.h
>
#include<conio.h>
#include<windows.h>
#include<stdlib.h>
#define BLACK 0
#define BLUE 1
#define GREEN 2
#define CYAN 3
#define RED 4
#define MAGENTA 5
#define BROWN 6
#define LIGHTGREY 7
#define DARKGREY 8
#define LIGHTBLUE 9
#define LIGHTGREEN 10
#define LIGHTCYAN 11
#define LIGHTRED 12
#define LIGHTMAGENTA 13
#define YELLOW 14
#define WHITE 15
#define BLINK 128
#define HANDLE


HANDLE  screen;
  
int textcolor = LIGHTGREEN;
int backgroundcolor = BLACK;
screen = GetStdHandle(STD_OUTPUT_HANDLE);
void TextColor(int fontcolor,int backgroundcolor,HANDLE screen)

{
   int color_attribute;
   color_attribute = backgroundcolor;
   color_attribute = _rotl(color_attribute,4) | fontcolor;
   SetConsoleTextAttribute(screen,color_attribute);
}
 
TextColor(textcolor,backgroundcolor ,screen); 
FillConsoleOutputAttribute(screen, _rotl(backgroundcolor,4) , 80 * 50,coord , &cWritten); 




class Converstion
{
	clrscr();
	float A;
	public:
		void FeetToInches()
		{
			cout<<"Enter Feet: ";
			cin>>A;
			cout<<A<<" Feet = "<<12*A<<" Inches\n";
		}
		void InchesToFeet()
		{
			cout<<"Enter Inches: ";
			cin>>A;
			cout<<A<<" Inches = "<<0.083*A<<" Feet\n";
		}

		void CelsiusToFahrenheit()
		{
			cout<<"Enter Temperature in Celsius: ";
			cin>>A;
			float t;
			t = A+40;
			t = (t*9/5)-40;

			cout<<A<<" Celsius = "<<t<<" Fahrenheit\n";
		}
		void FahrenheitToCelsius()
		{
			cout<<"Enter Temperature in Fahrenheit: ";
			cin>>A;

			float t;
			t = A+40;
			t = (t*5/9)-40;

			cout<<A<<" Fahrenheit = "<<t<<" Celsius\n";
		}

};

int main()
{
	
	Converstion C;
	while(1)
	{

	
		cout<<"\n1.Feet To Inches";
		cout<<"\n2.Inches To Feet";
		cout<<"\n3.Celsius To Fahrenheit";
		cout<<"\n4.Fahrenheit To Celsius";
		cout<<"\n5.Exit";
		cout<<"\n\nEnter ur choice:  ";
		int opt;
		cin>>opt;
		switch(opt)
		{
			case 1:
			       C.FeetToInches();
			       break;
			case 2:
			       C.InchesToFeet();
			       break;
			case 3:
			       C.CelsiusToFahrenheit();
			       break;
			case 4:
			       C.FahrenheitToCelsius();
			       break;
			case 5:
				cout<<"\n\t\t\tThank you...";
				cout<<"\n\t\t\t------------\n\n\n";
				getch();
				exit(0);

			default:
				cout<<"\n\t\t\tInvalid Option! Try again...";
				cout<<"\n\t\t\t----------------------------\n\n\n";
		}
		getch();
	}
	getch();
	return 0;
}

this is the program i need help about the extension part..


Extensions:

a) Find out what absolute zero is in both Fahrenheit and Celsius. Give an error, message if any temperature colder than absolute zero are entered.

b) Modify the inches to feet converter to use integer variables. Give the output as a mixed amount of feet and inches. For example, converting 27 inches to feet should give an output of “2 feet, 3 inches” instead of “2.25 feet.” Make sure that the program correctly uses the singular and plural forms of the word foot correctly. (i.e. “1 feet” or “3 foot” is not acceptable).

how to write an algotithm and flow chart to this program.. and how to make the program attractive, above in the program i have used some library functions to change the background color and also the text color.. pls chek out..
Thank you

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by vishesh
0

a) Absolute temperature in Celsius is -273C. Convert it to Fahrenheit and put an if condition wafter taking input.

b) To give output into this form try this:

int oFeet = inches/12;
in oInches = inches - (12*oFeet); // or simply: inches%12

if(oFeet==1) {
    cout << oFeet << "foot "  << oInches << "inches";
}
else {
    cout << " oFeet << "feet"  << oInches << "inches";
}

Also dont use getch() and clrscr() . Its non standard and somewhat borland specific. It seems that you are using Windows API so you could use WinAPI to clear screen and cin.get() for getch();

Even you have included header files which are not included the way you have done in Standard C++. But I think you are using some old compiler so you couldn't help it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.