I need to multiply but I don't know how

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>

using namespace std;

int main () {
    //declaring variables
    double Pi= 3.1416 ;
    double Diameter_ofcircle = 0.0;
    double priceofrailingmaterial = 0.0;
    double Totalpriceofrailingmaterial = 0.0;

    //Getting the user input

    cout<<"Enter the diameter of the circle ";
    cin>>Diameter_ofcircle ;

    cout<<"Enter the price of railing material per foot ";
    cin>> priceofrailingmaterial ;

    Totalpriceofrailingmaterial = ( (Diameter_ofcircle)* Pi ) * ( priceofrailingmaterial) ;

    cout<<"Total price of railing material "<<Totalpriceofrailingmaterial<<endl;

    return 0;
}


I need to add this in Visual Studio C++ and this is all I have

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#pragma once

namespace Diameter {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	/// <summary>
	/// Summary for Form1
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::Label^  label1;
	private: System::Windows::Forms::TextBox^  txtPi;
	protected: 

	private: System::Windows::Forms::Label^  label2;
	private: System::Windows::Forms::TextBox^  txtDiameter;

	private: System::Windows::Forms::Label^  label3;
	private: System::Windows::Forms::TextBox^  txtPrice;

	private: System::Windows::Forms::Label^  label4;
	private: System::Windows::Forms::TextBox^  txtTotal;

	private: System::Windows::Forms::Button^  btnClose;




	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->label1 = (gcnew System::Windows::Forms::Label());
			this->txtPi = (gcnew System::Windows::Forms::TextBox());
			this->label2 = (gcnew System::Windows::Forms::Label());
			this->txtDiameter = (gcnew System::Windows::Forms::TextBox());
			this->label3 = (gcnew System::Windows::Forms::Label());
			this->txtPrice = (gcnew System::Windows::Forms::TextBox());
			this->label4 = (gcnew System::Windows::Forms::Label());
			this->txtTotal = (gcnew System::Windows::Forms::TextBox());
			this->btnClose = (gcnew System::Windows::Forms::Button());
			this->SuspendLayout();
			// 
			// label1
			// 
			this->label1->AutoSize = true;
			this->label1->Location = System::Drawing::Point(12, 90);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(16, 13);
			this->label1->TabIndex = 0;
			this->label1->Text = L"Pi";
			// 
			// txtPi
			// 
			this->txtPi->BackColor = System::Drawing::SystemColors::Window;
			this->txtPi->Location = System::Drawing::Point(124, 87);
			this->txtPi->Name = L"txtPi";
			this->txtPi->ReadOnly = true;
			this->txtPi->Size = System::Drawing::Size(75, 20);
			this->txtPi->TabIndex = 1;
			this->txtPi->Text = L"3.1416";
			// 
			// label2
			// 
			this->label2->AutoSize = true;
			this->label2->Location = System::Drawing::Point(12, 32);
			this->label2->Name = L"label2";
			this->label2->Size = System::Drawing::Size(89, 13);
			this->label2->TabIndex = 2;
			this->label2->Text = L"Diameter of circle";
			// 
			// txtDiameter
			// 
			this->txtDiameter->Location = System::Drawing::Point(122, 29);
			this->txtDiameter->Name = L"txtDiameter";
			this->txtDiameter->Size = System::Drawing::Size(77, 20);
			this->txtDiameter->TabIndex = 3;
			// 
			// label3
			// 
			this->label3->AutoSize = true;
			this->label3->Location = System::Drawing::Point(12, 160);
			this->label3->Name = L"label3";
			this->label3->Size = System::Drawing::Size(154, 13);
			this->label3->TabIndex = 4;
			this->label3->Text = L"Price of railing material per foot ";
			// 
			// txtPrice
			// 
			this->txtPrice->Location = System::Drawing::Point(194, 215);
			this->txtPrice->Name = L"txtPrice";
			this->txtPrice->Size = System::Drawing::Size(142, 20);
			this->txtPrice->TabIndex = 5;
			// 
			// label4
			// 
			this->label4->AutoSize = true;
			this->label4->Location = System::Drawing::Point(12, 215);
			this->label4->Name = L"label4";
			this->label4->Size = System::Drawing::Size(142, 13);
			this->label4->TabIndex = 6;
			this->label4->Text = L"Total price  of raling material ";
			// 
			// txtTotal
			// 
			this->txtTotal->Location = System::Drawing::Point(194, 160);
			this->txtTotal->Name = L"txtTotal";
			this->txtTotal->Size = System::Drawing::Size(122, 20);
			this->txtTotal->TabIndex = 7;
			// 
			// btnClose
			// 
			this->btnClose->Location = System::Drawing::Point(241, 336);
			this->btnClose->Name = L"btnClose";
			this->btnClose->Size = System::Drawing::Size(75, 23);
			this->btnClose->TabIndex = 8;
			this->btnClose->Text = L"Close";
			this->btnClose->UseVisualStyleBackColor = true;
			this->btnClose->Click += gcnew System::EventHandler(this, &Form1::btnClose_Click);
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(686, 418);
			this->Controls->Add(this->btnClose);
			this->Controls->Add(this->txtTotal);
			this->Controls->Add(this->label4);
			this->Controls->Add(this->txtPrice);
			this->Controls->Add(this->label3);
			this->Controls->Add(this->txtDiameter);
			this->Controls->Add(this->label2);
			this->Controls->Add(this->txtPi);
			this->Controls->Add(this->label1);
			this->Name = L"Form1";
			this->Text = L"Form1";
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion

	private: System::Void btnClose_Click(System::Object^  sender, System::EventArgs^  e) {
				 Application::Exit();
			 }
};
}







Looks like you need to add a button, then assign it to do the math.

Don't see the need for you to include the value of PI in your form, I would simply put it in when you click the button.

Search google for "Visual C++ Youtube calculator"

I saw a couple good vids there about how to do exactly what your after.

Topic archived. No new replies allowed.