Published
- 3 min read
CPE263 Week Homework Demo
Week 3 Homework Demo

Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Homework
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
pictureBox1.ImageLocation = Application.StartupPath + "\\asset\\image\\coin-home.gif";
imgBitcoin.ImageLocation = Application.StartupPath + "\\asset\\image\\Bitcoin.png";
imgEthereum.ImageLocation = Application.StartupPath + "\\asset\\image\\Ethereum.png";
imgTether.ImageLocation = Application.StartupPath + "\\asset\\image\\Tether.png";
imgBNB.ImageLocation = Application.StartupPath + "\\asset\\image\\BNB.png";
imgDogecoin.ImageLocation = Application.StartupPath + "\\asset\\image\\Dogecoin.png";
}
private void btnBitcoin_Click(object sender, EventArgs e)
{
picCoin.ImageLocation = Application.StartupPath + "\\asset\\image\\Bitcoin.png";
}
private void btnEthereum_Click(object sender, EventArgs e)
{
picCoin.ImageLocation = Application.StartupPath + "\\asset\\image\\Ethereum.png";
}
private void btnTether_Click(object sender, EventArgs e)
{
picCoin.ImageLocation = Application.StartupPath + "\\asset\\image\\Tether.png";
}
private void btnBNB_Click(object sender, EventArgs e)
{
picCoin.ImageLocation = Application.StartupPath + "\\asset\\image\\BNB.png";
}
private void btnSolana_Click(object sender, EventArgs e)
{
picCoin.ImageLocation = Application.StartupPath + "\\asset\\image\\Solana.png";
}
private void btnUSDC_Click(object sender, EventArgs e)
{
picCoin.ImageLocation = Application.StartupPath + "\\asset\\image\\USDC.png";
}
private void btnXRP_Click(object sender, EventArgs e)
{
picCoin.ImageLocation = Application.StartupPath + "\\asset\\image\\XRP.png";
}
private void btnDogecoin_Click(object sender, EventArgs e)
{
picCoin.ImageLocation = Application.StartupPath + "\\asset\\image\\Dogecoin.png";
}
private void btnSum_Click(object sender, EventArgs e)
{
double btc, eth, usdt, bnb, doge, sum, dis, vat, pay;
btc = Convert.ToDouble(txtBitcoin.Text);
eth = Convert.ToDouble(txtEthereum.Text);
usdt = Convert.ToDouble(txtTether.Text);
bnb = Convert.ToDouble(txtBNB.Text);
doge = Convert.ToDouble(txtDogecoin.Text);
sum = btc + eth + usdt + bnb + doge;
dis = sum * (15.0 / 100);
vat = (sum - dis) * (7.0 / 100);
pay = (sum - dis) + vat;
MessageBox.Show("SUM : \t\t\t" + sum.ToString() +
"\nDiscount 15% : \t\t" + dis.ToString() +
"\nVat 7% : \t\t\t" + vat.ToString()+
"\nPay : \t\t\t" + pay.ToString()
);
}
private string password = ""; // Use a field or property instead of const
private void btnSignUp_Click(object sender, EventArgs e)
{
string suPass = txtPasswordSignUp.Text;
string cfPass = txtCfPasswordSignUp.Text;
if (suPass == cfPass)
{
MessageBox.Show("Sign In successfully");
password = suPass; // Update the password field
}
else
{
MessageBox.Show("Password does not match");
password = ""; // Clear the password field
}
}
private void btnLogin_Click(object sender, EventArgs e)
{
string pass;
pass = txtPasswordSignIn.Text;
if (pass == password)
MessageBox.Show("Login succeesfully");
else
MessageBox.Show("Password Incorrect");
}
private void btnSubmit_Click(object sender, EventArgs e)
{
string name, lname, sex, status, submit = "";
name = txtName.Text;
lname = txtLastName.Text;
// gender
if (radMale.Checked)
sex = radMale.Text;
else if (radFemale.Checked)
sex = radFemale.Text;
else
sex = radLgbt.Text;
// marital status
if (radSingle.Checked)
status = radSingle.Text;
else if (radMarried.Checked)
status = radMarried.Text;
else
status = "Not specified";
submit = $"Name: {name}\r\n" +
$"Last Name: {lname}\r\n" +
$"Gender: {sex}\r\n" +
$"Status: {status}";
picProfile.ImageLocation = Application.StartupPath + "\\asset\\image\\profile.png";
txtSubmit.Text = submit.ToString();
}
}
}