0% found this document useful (0 votes)
72 views11 pages

Form1 Form Groupbox Radiobutton Radiobutton Radiobutton Radiobutton Radiobutton Radiobutton Button

The document describes a C# program that presents the user with a 7 question multiple choice quiz. For each question, the user is shown 4 possible answers and must select the correct one. The user's selection is checked and they are awarded 10 points for a correct answer. After all questions, the user's total score is displayed. The questions cover topics like capital cities, famous people, landmarks, and general knowledge. The program uses radio buttons, switches, and other common C# and console programming elements to present the quiz and track the user's score.

Uploaded by

Ion Popescu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views11 pages

Form1 Form Groupbox Radiobutton Radiobutton Radiobutton Radiobutton Radiobutton Radiobutton Button

The document describes a C# program that presents the user with a 7 question multiple choice quiz. For each question, the user is shown 4 possible answers and must select the correct one. The user's selection is checked and they are awarded 10 points for a correct answer. After all questions, the user's total score is displayed. The questions cover topics like capital cities, famous people, landmarks, and general knowledge. The program uses radio buttons, switches, and other common C# and console programming elements to present the quiz and track the user's score.

Uploaded by

Ion Popescu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Problema 1;

using
using
using
using
using
using

System;
System.Drawing;
System.Collections;
System.ComponentModel;
System.Windows.Forms;
System.Data;

public class Form1 : System.Windows.Forms.Form


{
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.RadioButton radioButton3;
private System.Windows.Forms.RadioButton radioButton4;
private System.Windows.Forms.RadioButton radioButton5;
private System.Windows.Forms.RadioButton radioButton6;
private System.Windows.Forms.Button button1;
public Form1()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton3 = new System.Windows.Forms.RadioButton();
this.radioButton4 = new System.Windows.Forms.RadioButton();
this.radioButton5 = new System.Windows.Forms.RadioButton();
this.radioButton6 = new System.Windows.Forms.RadioButton();
this.radioButton1,
this.radioButton2,
this.radioButton3,
this.radioButton4,
this.radioButton5,
this.radioButton6});
this.groupBox1.Location = new System.Drawing.Point(5, 5);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(400, 400);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Selectati problema:";

// radioButton1
//
this.radioButton1.Location = new System.Drawing.Point(8, 20);
this.radioButton1.Name = "radioButton1";
this.radioButton1.TabIndex = 4;
this.radioButton1.Text = "Problema 1";
this.radioButton1.CheckedChanged += new
System.EventHandler(this.radioButton1_CheckedChanged);
//
// radioButton2
//
this.radioButton2.Location = new System.Drawing.Point(8, 50);
this.radioButton2.Name = "radioButton2";
this.radioButton2.TabIndex = 5;
this.radioButton2.Text = "Problema 2";
this.radioButton2.CheckedChanged += new
System.EventHandler(this.radioButton2_CheckedChanged);
//
// radioButton3
//
this.radioButton3.Location = new System.Drawing.Point(8, 80);
this.radioButton3.Name = "radioButton3";

this.radioButton3.TabIndex = 6;
this.radioButton3.Text = "Problema 3";
this.radioButton3.CheckedChanged += new
System.EventHandler(this.radioButton3_CheckedChanged);
//
//radioButton4
this.radioButton4.Location = new System.Drawing.Point(8, 110);
this.radioButton4.Name = "radioButton4";
this.radioButton4.TabIndex = 7;
this.radioButton4.Text = "Problema 4";
this.radioButton4.CheckedChanged += new
System.EventHandler(this.radioButton4_CheckedChanged);
//
//radioButton5
this.radioButton5.Location = new System.Drawing.Point(8, 140);
this.radioButton5.Name = "radioButton5";
this.radioButton5.TabIndex = 8;
this.radioButton5.Text = "Problema 5";
this.radioButton5.CheckedChanged += new
System.EventHandler(this.radioButton5_CheckedChanged);
//
//radioButton6
this.radioButton6.Location = new System.Drawing.Point(8, 170);
this.radioButton6.Name = "radioButton3";
this.radioButton6.TabIndex = 9;
this.radioButton6.Text = "Problema 6";
this.radioButton6.CheckedChanged += new
System.EventHandler(this.radioButton6_CheckedChanged);
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(408, 317);
this.Controls.AddRange(new System.Windows.Forms.Control[] {this.groupBox1});
this.Name = "Form1";
this.Text = "Laboratorul Nr.1------MIDPS";
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
static void Main()
{
Application.Run(new Form1());
}

private void radioButton1_CheckedChanged(object sender, System.EventArgs e)


{
if (radioButton1.Checked)
{
Console.Clear();
Console.WriteLine("Bonjour,FI-101");
}
}
private void radioButton2_CheckedChanged(object sender, System.EventArgs e)
{
if (radioButton2.Checked)
{
Console.Clear();
string temp;
Console.Write("Introduisez un string: ");
temp = Console.ReadLine();
Console.Write("String inversee: ");
for (int i = temp.Length - 1; i >= 0; i--)
{
Console.Write(temp[i]);
}
}
}

private void radioButton3_CheckedChanged(object sender, System.EventArgs e)


{
if (radioButton3.Checked)
{
Console.Clear();
string s1, s2, s3;
Console.WriteLine("Introduceti primul string:");
s1 = Console.ReadLine();
Console.WriteLine("Introduceti al II string:");
s2 = Console.ReadLine();
s3 = s1 + s2;
bool b = true;
while (b)
{
Console.WriteLine("Introduceti un numar 1-3:");
int tmp = Convert.ToInt32(Console.ReadLine());
switch (tmp)
{
case 1:
Console.WriteLine("Concatenarea sirurilor:{0}", s3);
break;
case 2:
Console.WriteLine("Primul sir introdus:{0}", s1);
break;
case 3:
Console.WriteLine("Al II sir introdus este:{0}", s2);
break;
default:
Console.WriteLine("Selectare invalida.Alegeti 1, 2, sau 3.");
break;
case 0:
Environment.Exit(0);
break;
}

}
}
private void radioButton4_CheckedChanged(object sender, System.EventArgs e)
{
if (radioButton4.Checked)
{
Console.Clear();
int nota;
string s;
bool b;
b = true;
while (b)
{
Console.WriteLine("Introduceti nota:");
s = Console.ReadLine();
nota = Convert.ToInt32(s);
if (nota > 4 && nota <= 10)
{
Console.WriteLine("Studentul a trecut cu succes examenul,nota valida");
}
else
{
Console.WriteLine("Nota este invalida");
Console.ReadKey();
Environment.Exit(0);
}
}
}
}
private void radioButton5_CheckedChanged(object sender, System.EventArgs e)
{
if (radioButton5.Checked)

Console.Clear();
bool b;
b = true;
while (b)
{
Console.WriteLine("Introduceti un numar 1-7:");
int tmp = Convert.ToInt32(Console.ReadLine());
switch (tmp)
{
case 1:
Console.WriteLine("Ziua selectata este Luni");
break;
case 2:
Console.WriteLine("Ziua selectata este Marti");
break;
case 3:
Console.WriteLine("Ziua selectata este Miercuri");
break;
case 4:
Console.WriteLine("Ziua selectata este Joi");
break;
case 5:
Console.WriteLine("Ziua selectata este Vineri");
break;
case 6:
Console.WriteLine("Ziua selectata este Simbata");
break;
case 7:
Console.WriteLine("Ziua selectata este Duminica");
break;
default:
Console.WriteLine("Selectare invalida.Alegeti variantele 1-7.");
break;
case 0:
Environment.Exit(0);
break;
}

}
}
private void radioButton6_CheckedChanged(object sender, System.EventArgs e)
{
if (radioButton6.Checked)
{
Console.Clear();
Console.WriteLine("Introduceti numarul de elemente al vectorului:");
int n = int.Parse(Console.ReadLine());
int[] tab = new int[n];
int aux;
for (int i = 0; i < n; i++)
{
Console.WriteLine("Elementul {0} este: ", i);
tab[i] = int.Parse(Console.ReadLine());
}
// selectie directa
for (int i = 0; i < n - 1; i++)
for (int j = i + 1; j < n; j++)
if (tab[j] > tab[i])
{
aux = tab[i];
tab[i] = tab[j];
tab[j] = aux;
}
//afisarea sirului sortat
Console.WriteLine("Sirul sortat este:");

for (int i = 0; i < n; i++)


Console.WriteLine("{0}", tab[i]);
}

Problema 2:
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

namespace Test_Grila
{
class Program
{
static void Main(string[] args)
{
int coeff = 0;
Console.WriteLine("SUNTETI GATA DE TEST?VA UREZ SUCCES!!!");
Console.WriteLine();
Console.WriteLine("I.Care este capitala Lituaniei ?");
Console.WriteLine();
Console.WriteLine("1.Riga");
Console.WriteLine("2.Vilnius");
Console.WriteLine("3.Reikjavic");
Console.WriteLine("4.Sofia");
Console.WriteLine();
Console.Write("Varianta corecta:");
int n = Convert.ToInt32(Console.ReadLine());
switch (n)
{
case 1:
break;
case 2:
coeff += 10;
break;
case 3:
break;
case 4:
break;
default:
Console.WriteLine("Selectare invalida");

break;
}
Console.Clear();
Console.WriteLine("II.La ce club evolueaza in prezent portarul roman Costel
Pantelimon?");
Console.WriteLine();
Console.WriteLine("1.Real Madrid");
Console.WriteLine("2.Manchester United");
Console.WriteLine("3.Barcelona");
Console.WriteLine("4.Manchester City");
Console.WriteLine();
Console.Write("Varianta corecta:");
int m = Convert.ToInt32(Console.ReadLine());
switch (m)
{
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
coeff += 10;
break;
}
Console.Clear();
Console.WriteLine("III.Ce inaltime are Turnul Eiffel:");
Console.WriteLine();
Console.WriteLine("1.520 m");
Console.WriteLine("2.290 m");
Console.WriteLine("3.324 m");
Console.WriteLine("4.382 m");
Console.WriteLine();
Console.Write("Varianta corecta:");
int i = Convert.ToInt32(Console.ReadLine());
switch (i)
{
case 1:
break;
case 2:
break;
case 3:
coeff += 10;
break;
case 4:
break;
}
Console.Clear();
Console.WriteLine("IV.Citi ani a domnit Stefan cel Mare:");
Console.WriteLine();
Console.WriteLine("1.47 ani");
Console.WriteLine("2.23 ani");
Console.WriteLine("3.55 ani");
Console.WriteLine("4.19 ani");
Console.WriteLine();
Console.Write("Varianta corecta:");
int j = Convert.ToInt32(Console.ReadLine());
switch (j)
{
case 1:
coeff += 10;
break;
case 2:
break;
case 3:
break;
case 4:
break;
}
Console.Clear();

Console.WriteLine("V.Cine a spus ca:Lumea nu este centrul Universului?");


Console.WriteLine();
Console.WriteLine("1.A.Enstein");
Console.WriteLine("2.Frederico Taylor");
Console.WriteLine("3.Galileo Galilei");
Console.WriteLine("4.Bill Gates");
Console.WriteLine();
Console.Write("Varianta corecta:");
int k = Convert.ToInt32(Console.ReadLine());
switch (k)
{
case 1:
break;
case 2:
break;
case 3:
coeff += 10;
break;
case 4:
break;
}
Console.Clear();
Console.WriteLine("VI.Cite ore sunt intr-o saptamina");
Console.WriteLine();
Console.WriteLine("1.174");
Console.WriteLine("2.168");
Console.WriteLine("3.166");
Console.WriteLine("4.158");
Console.WriteLine();
Console.Write("Varianta corecta:");
int l = Convert.ToInt32(Console.ReadLine());
switch (l)
{
case 1:
break;
case 2:
coeff += 10;
break;
case 3:
break;
case 4:
break;
}
Console.Clear();
Console.WriteLine("VII.Care oras fabrica mai multe masini in U.S.A");
Console.WriteLine();
Console.WriteLine("1.Detroit");
Console.WriteLine("2.New York");
Console.WriteLine("3.Washington");
Console.WriteLine("4.Florida");
Console.WriteLine();
Console.Write("Varianta corecta:");
int r = Convert.ToInt32(Console.ReadLine());
switch (r)
{
case 1:
coeff += 10;
break;
case 2:
break;
case 3:
break;
case 4:
break;
}
Console.Clear();
Console.WriteLine("VIII.Cite kilograme cintareste pinguinul imperial:");
Console.WriteLine();

Console.WriteLine("1.40");
Console.WriteLine("2.32");
Console.WriteLine("3.53");
Console.WriteLine("4.35");
Console.WriteLine();
Console.Write("Varianta corecta:");
int b = Convert.ToInt32(Console.ReadLine());
switch (b)
{
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
coeff += 10;
break;
}
Console.Clear();
Console.WriteLine("IX.In ce an s-a stins din viata Mihai Eminescu:");
Console.WriteLine();
Console.WriteLine("1.1896");
Console.WriteLine("2.1902");
Console.WriteLine("3.1889");
Console.WriteLine("4.1884");
Console.WriteLine();
Console.Write("Varianta corecta:");
int c = Convert.ToInt32(Console.ReadLine());
switch (c)
{
case 1:
break;
case 2:
break;
case 3:
coeff += 10;
break;
case 4:
break;
}
Console.Clear();
Console.WriteLine("X.Cine este actalul 'presedinte' al Republicii Moldova:");
Console.WriteLine();
Console.WriteLine("1.Vlad Filat");
Console.WriteLine("2.Nicolae Timofti");
Console.WriteLine("3.Vlad Plahotniuc");
Console.WriteLine("4.Marian Lupu");
Console.WriteLine();
Console.Write("Varianta corecta:");
int t = Convert.ToInt32(Console.ReadLine());
switch (t)
{
case 1:
break;
case 2:
coeff += 10;
break;
case 3:
break;
case 4:
break;
}
Console.Clear();
Console.WriteLine("Ati acumulat:"+ coeff+"puncte");
if (coeff>=0 && coeff<=20) {Console.WriteLine("Aveti o cultura generala vaga.Nu ar
strica sa cititi niste carti.");}
if (coeff > 20 && coeff <= 50) { Console.WriteLine("Cultura generala a dvs este la nivel
mediu."); }

if (coeff > 50 && coeff <= 80) { Console.WriteLine("Sunteti aproape de perfectiune.Mult


succes"); }

if (coeff > 80 && coeff <= 100) { Console.WriteLine("Perfectiunea totala!"); }


Console.ReadLine();
}

Concluzie:
Efectuind aceasta lucrare de laborator am studiat bazele
programarii in C#.Prima problema am rezolvat utilizind o forma
pentru a comuta problemele.Testul l-am realizat simplu utilizind
doar instructiunea switch,case.

Universite Technique du Moldova


Facultate dOrdinateurs,Informatique et Microelectronique
Filiere Francophone Informatique

Rapport
Travail de laboratoire Nr.1
Discpline:MIDPS
Theme:Etudier les notions de base C#

A elabore:

et.gr.FI-101
Turetchi Gheorghe

A verifie:

professeur
Antohi Ionel

Chisinau 2013
Problme1 : Salut
Rcrire le programme salut pour qu'il affiche un message personnalis pass sur la
ligne de commande.
Ex : Hello : de moi mme!
Problme2 : Strings
Le string pass sur la ligne de commande, doit saffiche en ordre inverse.
Ex : introduisez 12345 , return 54321
Problme3 : Oprations

Ecrire un programme qui lit deux strings passs sur la ligne de commande et quand
on appuie sur : 1 - affiche le concatnation, 2- affichage du premire string, 3affichage du deuxime string.
Problme4 : Notes
Ecrire un programme qui lit une note passe sur la ligne de commande et qui
indique si elle est suffisante pour russir un examen. Si cest pas une note valide
alors faites le sortir du programme avec Environment.Exit()
Problme5 : Mois
Ecrire un programme qui lit le nombre entier entre 1 et 7 pass en paramtre et qui
affiche le nom de la jour correspondant.
Problme6 : Tableau
Ecrire un programme qui sorte un tableau de 10 lments en ordre dcroissant
(selon le dsir sans un algorithme exact), les lments sont pris de la ligne de
commande.
Faire un petite test dans Visual Studio, type Console Application, langage C#.
Ex :
I .Votre qualit principale, cest dtre ?
1. Optimiste (1p)
2. Tolrant (1p)
3. Davoir une bonne facult danalyse (1p)
4. Efficace (1p)
Chaque rponse est estim avec un score quelconque, la fin du test on peut
obtenir une somme de ces points et en dpendance du score accumul on nous
affiche une caractristique de notre personnalit.

You might also like