im trying to make a pizza order but why doesnt the result have decimals even though it is double
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace PizzaChat
{
/// <summary>
/// Description of MainForm.
/// </summary>
public partial class MainForm : Form
{
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
Question
anonymouses
im trying to make a pizza order but why doesnt the result have decimals even though it is double
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace PizzaChat
{
/// <summary>
/// Description of MainForm.
/// </summary>
public partial class MainForm : Form
{
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
void OrdbtClick(object sender, EventArgs e)
{
double amount, amountqua;
int quantity = int.Parse(quantb.Text);
double crust1 = 0.00;
double size = 0.00;
double cheese = 12.75, anchovies = 18.50, ham = 40.90, veg = 50.75, pineapple = 75.50, pepperoni = 45.50;
double toppings;
double toppings1 = 0.00,toppings2 = 0.00,toppings3 = 0.00,toppings4 = 0.00,toppings5 = 0.00,toppings6 = 0.00;
if (thkrdbt.Checked)
{
if(panrdbt.Checked)
{
crust1 = 150.75;
size = 100.00;
}
else if (regrdbt.Checked)
{
crust1 = 150.75;
size = 200.00;
}
else if (parrdbt.Checked)
{
crust1 = 150.75;
size = 400.00;
}
}
else if (thinrdbt.Checked)
{
if(panrdbt.Checked)
{
crust1 = 275.50;
size = 100.00;
}
else if (regrdbt.Checked)
{
crust1 = 275.50;
size = 200.00;
}
else if (parrdbt.Checked)
{
crust1 = 275.50;
size = 400.00;
}
}
else
{
MessageBox.Show("ERROR","ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
{
if (chechkbx.Checked)
{
toppings1 = cheese;
}
if (anchkbx.Checked)
{
toppings2 = anchovies;
}
if (hmchkbx.Checked)
{
toppings3 = ham;
}
if (vegchkbx.Checked)
{
toppings4 = veg;
}
if (pnpchkbx.Checked)
{
toppings5 = pineapple;
}
if (peppechkbx.Checked)
{
toppings6 = pepperoni;
}
}
toppings = toppings1 + toppings2 + toppings3 + toppings4 +toppings5 + toppings6;
amount = crust1 + size + toppings;
amountqua = quantity * amount;
lblamount.Text = amount.ToString(lblamount.Text + " PHP");
}
void ExbtClick(object sender, EventArgs e)
{
Application.Exit();
}
void MainFormLoad(object sender, EventArgs e)
{
}
}
}
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now