Advertisement
DrAungWinHtut

Multiple Choice

Mar 1st, 2022
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.86 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO; /// <summary>
  11. ///
  12. /// </summary>
  13.  
  14. namespace _2022022401_CS_Login_Exam_2
  15. {
  16.     public partial class frmPhysics : Form
  17.     {
  18.         int iPhysicsPages = 0;
  19.         int iPhysicTotalMarks = 0;
  20.         public frmPhysics()
  21.         {
  22.             InitializeComponent();
  23.         }
  24.  
  25.         private void frmPhysics_Load(object sender, EventArgs e)
  26.         {
  27.             txtPhysicsQuestion.Text = "Speed of light is ......";
  28.             lblAns1.Text = "(a) 299 792 458 m/s";
  29.             lblAns2.Text = "(b) 499 792 458 m/s";
  30.             lblAns3.Text = "(c) 999 792 458 m/s";
  31.  
  32.  
  33.  
  34.         }
  35.  
  36.         private void btnSubmit_Click(object sender, EventArgs e)
  37.         {
  38.            
  39.             string sAns = txtMultipleChoice .Text;
  40.             if(sAns == "a")
  41.             {
  42.                 iPhysicTotalMarks += 10;
  43.                 MessageBox.Show("Correct Answer!");
  44.                 txtPhysicsTotalMarks.Text = iPhysicTotalMarks.ToString();
  45.             }
  46.             else
  47.             {
  48.                 MessageBox.Show("Wrong Answer!");
  49.             }
  50.         }
  51.  
  52.         private void btnNextPhysicsQuestion_Click(object sender, EventArgs e)
  53.         {
  54.             iPhysicsPages++;
  55.             string sPhysicsQuestion = "";
  56.  
  57.  
  58.             StreamReader srPhysicsQuestion = new StreamReader("physics_questions.txt");
  59.             sPhysicsQuestion = srPhysicsQuestion.ReadToEnd();
  60.  
  61.             txtPhysicsQuestion.Text = sPhysicsQuestion ;
  62.             lblAns1.Text = "";
  63.             lblAns2.Text = "";
  64.             lblAns3.Text = "";
  65.             txtMultipleChoice.Clear();
  66.             txtMultipleChoice.Focus();
  67.         }
  68.     }
  69. }
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement