sfareed
asked on
MessageBox along with if and else statement
I am new in C#.
I am creating a MessageBox for user option , please help me to fix the code, I am new in C#
Depending on the answer (NO = local plan or YES = nationwide plan), display a second MessageBox showing the appropriate prices: $23.99 a month for the local plan or $59.99 a month for the nationwide plan.
Here is the code, please help me to fix this code
************************
namespace Wireless
{
using System;
using System.Windows.Forms;
public class Wireless
{
public static void Main()
{
string question="Do you want a nationwide plan?";
string caption ="Wireless Plan";
double price = 23.00;
if (MessageBox.Show(question, caption,MessageBoxButtons. YesNo, MessageBoxIcon.Question)== DialogResu lt.Yes)
price +=36.99;
{
MessageBox.Show(price.ToSt ring("C") + " a month for the Nation wide plan");
}
else
(MessageBox.Show(question, caption,MessageBoxButtons. YesNo, MessageBoxIcon.Question)== DialogResu lt.No);
price +=0.99;
{
MessageBox.Show(price.ToSt ring("C") + " a month for the local plan");
}
}
}
}
I am creating a MessageBox for user option , please help me to fix the code, I am new in C#
Depending on the answer (NO = local plan or YES = nationwide plan), display a second MessageBox showing the appropriate prices: $23.99 a month for the local plan or $59.99 a month for the nationwide plan.
Here is the code, please help me to fix this code
************************
namespace Wireless
{
using System;
using System.Windows.Forms;
public class Wireless
{
public static void Main()
{
string question="Do you want a nationwide plan?";
string caption ="Wireless Plan";
double price = 23.00;
if (MessageBox.Show(question,
price +=36.99;
{
MessageBox.Show(price.ToSt
}
else
(MessageBox.Show(question,
price +=0.99;
{
MessageBox.Show(price.ToSt
}
}
}
}
you might also make the follwing a bit easier to read:
> if (MessageBox.Show(question, caption,MessageBoxButtons. YesNo, MessageBoxIcon.Question)== DialogResu lt.Yes)
DialogResult user_choice = MessageBox.Show(question, caption,MessageBoxButtons. YesNo, MessageBoxIcon.Question);
if (user_choice == DialogResult.Yes)
{
..
}
else
{
...
}
> if (MessageBox.Show(question,
DialogResult user_choice = MessageBox.Show(question, caption,MessageBoxButtons.
if (user_choice == DialogResult.Yes)
{
..
}
else
{
...
}
ASKER
Before I submit 250 points for you,
could you please let me know how can I add third option (cancel)on the message
box.
User has three option
1) Yes
2) No
3) Cancel(which gonna end the program.
thanks for your help
could you please let me know how can I add third option (cancel)on the message
box.
User has three option
1) Yes
2) No
3) Cancel(which gonna end the program.
thanks for your help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I really appreciate your help
take care
take care
{
string question="Do you want a nationwide plan?";
string caption ="Wireless Plan";
double price = 23.00;
if (MessageBox.Show(question,
{
price +=36.99;
MessageBox.Show(price.ToSt
}
else
{
price +=0.99;
MessageBox.Show(price.ToSt
}
}