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

Dani AI

Generated

A compact, practical add-on that fills the gaps in the thread and maps cleanly to an algorithm/flowchart while avoiding non‑portable calls.

  • Short plan: present a letter menu (A–D), read a single character and normalize it with toupper, validate the choice, then call the appropriate conversion routine. For temperature conversions check against the physical lower bound (use precise constants), perform the standard formulas, and format fractional output with fixed << setprecision(2). For the inches→feet extension use integer math to produce a mixed feet+inches result and choose the correct singular/plural word forms.

  • Algorithm / flowchart hints (use these shapes: oval = Start/End, parallelogram = I/O, rectangle = process, diamond = decision):

    1. Start → show menu (I/O).
    2. Read choice (I/O) → normalize to uppercase (process).
    3. Decision: valid choice? → if no, print error and loop.
    4. For a temp conversion: read numeric input → decision: below absolute zero? → if yes print error, else compute using standard formula and print result rounded to 2 decimals.
    5. For inches→feet (integer mode): read integer inches → feet = inches / 12, rem = abs(inches) % 12 → print with correct singular/plural.
    6. Loop back to menu until Exit → End.
  • Small, focused code tips (use only standard headers: <iostream>, <iomanip>, <cctype>, <limits>, <cmath>):

    const double ABS_ZERO_C = -273.15;
    const double ABS_ZERO_F = -459.67;
    char ch; cin >> ch;
    ch = static_cast<char>(toupper(static_cast<unsigned char>(ch)));
    cout << fixed << setprecision(2) << value << '\n';
  • Practical cautions and tests: follow ’s advice and remove conio.h/clrscr()/getch() for portable code; use cin.fail() + cin.clear() + cin.ignore(...) to recover from bad input. Test edge cases (exact absolute‑zero values, slightly below, zero, negative inches, large values). For UI polish use clear prompts, explicit unit labels, and consistent rounding; if platform colors are desired prefer modern terminal escape sequences or a GUI rather than compiler/IDE‑specific APIs.

This complements the existing thread by turning the high‑level requirements into a concrete algorithm, giving safe input handling, precise constants for physical limits, and small standard C++ idioms to produce the required two‑decimal output and correct mixed‑unit formatting.

Member Avatar for Member #114696

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.