Click here to Skip to main content
15,885,145 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralCStatic background color problem Pin
Coremn15-Feb-04 19:32
Coremn15-Feb-04 19:32 
GeneralRe: CStatic background color problem Pin
Prakash Nadar15-Feb-04 19:55
Prakash Nadar15-Feb-04 19:55 
GeneralRe: CStatic background color problem Pin
Coremn16-Feb-04 11:45
Coremn16-Feb-04 11:45 
GeneralRe: CStatic background color problem Pin
Prakash Nadar16-Feb-04 16:40
Prakash Nadar16-Feb-04 16:40 
GeneralSave Bitmap from Device Context to File Pin
Okeno Palmer15-Feb-04 17:14
Okeno Palmer15-Feb-04 17:14 
GeneralRe: Save Bitmap from Device Context to File Pin
Johann Gerell15-Feb-04 20:14
Johann Gerell15-Feb-04 20:14 
GeneralWeird toolbar behaviour Pin
Deian15-Feb-04 16:18
Deian15-Feb-04 16:18 
GeneralHelp...program passes input as 13... Pin
kfresh15-Feb-04 15:47
kfresh15-Feb-04 15:47 
i'm a bit of c++ newbie... using VS .NET compiler

for this little prgram i'm working on, has to find the area and perimeter of a circle, triangle, or a square depending on user's choice.The choices are included in a menu. This menu should also include a way of exiting the program. The input will depend on the choice selected and i have to make sure that users will not enter a choice that is not listed in the menu. Also, make sure no negative or zero values are entered

i'm not done with all the aspects of this program, but below is what i have. program is it runs with no errors, but any time i enter a number for radius, base, height, or side value, it passes the value as 13 and does all the calculations using 13.

Can any one give me a clue where i'm messin up at???

//<br />
<br />
#include "stdafx.h"<br />
#using <mscorlib.dll><br />
#include <conio.h><br />
using namespace System;<br />
<br />
void calcCircle(double);<br />
void calcTriangle(double, double, double);<br />
void calcSquare(double);<br />
<br />
int main()<br />
{<br />
	double circle_radius = 0.0;<br />
	double tri_base = 0.0;<br />
	double tri_height = 0.0;<br />
	double tri_side = 0.0;<br />
	double square_base = 0.0;<br />
	int figures = 0;<br />
<br />
	Console::Write("Choose a geometric figure: \n");<br />
	Console::Write("1. Circle\n");<br />
	Console::Write("2. Triangle\n");<br />
	Console::Write("3. Square\n");<br />
	Console::WriteLine("4. Exit");<br />
	figures = Console::Read();<br />
<br />
	switch (figures)<br />
	{<br />
	case '1':		Console::WriteLine("Enter Radius: ");<br />
					circle_radius = Console::Read();<br />
					getch();<br />
					calcCircle(circle_radius);<br />
		break;<br />
	case '2':		Console::WriteLine("Enter Base: ");<br />
					tri_base = Convert::ToDouble(Console::Read());<br />
					if (tri_base > 0)<br />
						Console::WriteLine(tri_base);<br />
					else<br />
						Console::WriteLine("Wrong Value");<br />
					Console::Write("Enter Height: ");<br />
					tri_height = Convert::ToDouble(Console::Read());<br />
					Console::Write("Enter A Non-base side: ");<br />
					tri_side = Convert::ToDouble(Console::Read());<br />
					getch();<br />
					calcTriangle(tri_base, tri_height, tri_side);<br />
		break;<br />
	case '3':		Console::Write("Enter A Side: ");<br />
					square_base = Convert::ToDouble(Console::Read());<br />
					getch();<br />
					calcSquare(square_base);<br />
		break;<br />
	case '4':;<br />
		break;<br />
	default:		Console::WriteLine("Wrong Choice. Please Select A Right One");<br />
	}<br />
	getch();<br />
	return 0;<br />
}<br />
<br />
void calcCircle(double radius)<br />
{<br />
	double circle_area = 0.0;<br />
	double circle_peri = 0.0;<br />
	circle_area = 3.14159265 * Math::Pow(radius,2);<br />
	circle_peri = 2.0 * 3.14159265 * radius;<br />
	Console::WriteLine("Radius: {0}", Convert::ToString(radius));<br />
	Console::WriteLine("Area: {0}", Convert::ToString(circle_area));<br />
	Console::WriteLine("Perimeter: {0}", Convert::ToString(circle_peri));<br />
	getch();<br />
}<br />
<br />
void calcTriangle(double base, double height, double side)<br />
{<br />
	double tri_area = 0.0;<br />
	double tri_peri = 0.0;<br />
	tri_area = base * height / 2.0;<br />
	tri_peri = base + side + side;<br />
	Console::WriteLine("Area: {0}", Convert::ToString(tri_area));<br />
	Console::WriteLine("Perimeter: {0}", Convert::ToString(tri_peri));<br />
	getch();<br />
}<br />
<br />
void calcSquare(double sq_base)<br />
{<br />
	double square_area = 0.0;<br />
	double square_peri = 0.0;<br />
	square_area = Math::Pow(sq_base,2);<br />
	square_peri = 4.0 * sq_base;<br />
	Console::WriteLine("Area: {0}", Convert::ToString(square_area));<br />
	Console::WriteLine("Perimeter: {0}", Convert::ToString(square_peri));<br />
	getch();<br />
}<br />

GeneralRe: Help...program passes input as 13... Pin
Andrew Walker15-Feb-04 16:37
Andrew Walker15-Feb-04 16:37 
General.ico corruption and CVS Pin
Jon Sagara15-Feb-04 15:30
Jon Sagara15-Feb-04 15:30 
GeneralRe: .ico corruption and CVS Pin
Mike Dimmick16-Feb-04 2:42
Mike Dimmick16-Feb-04 2:42 
GeneralRe: .ico corruption and CVS Pin
Jon Sagara16-Feb-04 2:48
Jon Sagara16-Feb-04 2:48 
GeneralAddPicture Pin
Member 73893815-Feb-04 15:10
Member 73893815-Feb-04 15:10 
GeneralFree Unix OS download.. Pin
IrishSonic15-Feb-04 14:41
IrishSonic15-Feb-04 14:41 
GeneralRe: Free Unix OS download.. Pin
Maxwell Chen15-Feb-04 15:14
Maxwell Chen15-Feb-04 15:14 
GeneralRe: Free Unix OS download.. Pin
Anonymous15-Feb-04 19:37
Anonymous15-Feb-04 19:37 
GeneralRe: Free Unix OS download.. Pin
Okeno Palmer16-Feb-04 1:23
Okeno Palmer16-Feb-04 1:23 
GeneralRe: Free Unix OS download.. Pin
IrishSonic17-Feb-04 13:22
IrishSonic17-Feb-04 13:22 
GeneralA simple problem Pin
deniz79s15-Feb-04 6:10
deniz79s15-Feb-04 6:10 
GeneralRe: A simple problem Pin
Mike Dimmick16-Feb-04 2:59
Mike Dimmick16-Feb-04 2:59 
GeneralMFC control and value variable conflict Pin
Dev57815-Feb-04 5:31
Dev57815-Feb-04 5:31 
GeneralRe: MFC control and value variable conflict Pin
Michael Dunn15-Feb-04 5:35
sitebuilderMichael Dunn15-Feb-04 5:35 
GeneralRe: MFC control and value variable conflict Pin
Prakash Nadar15-Feb-04 19:59
Prakash Nadar15-Feb-04 19:59 
GeneralRe: MFC control and value variable conflict Pin
jhwurmbach16-Feb-04 0:08
jhwurmbach16-Feb-04 0:08 
GeneralRe: MFC control and value variable conflict Pin
Prakash Nadar16-Feb-04 2:54
Prakash Nadar16-Feb-04 2:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.