0% found this document useful (0 votes)
3 views

LecDemo2

The document is a C# program that prompts the user to enter their name, faculty, and department, and then displays this information formatted within asterisks. It includes variable declarations for different data types, such as string, int, decimal, and char. The program also demonstrates parsing string inputs into numeric types for further processing.

Uploaded by

aidenpatel04
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

LecDemo2

The document is a C# program that prompts the user to enter their name, faculty, and department, and then displays this information formatted within asterisks. It includes variable declarations for different data types, such as string, int, decimal, and char. The program also demonstrates parsing string inputs into numeric types for further processing.

Uploaded by

aidenpatel04
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

using System;

using System.Collections.Generic;
using System.Linq;
using System.Net.Security;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

namespace LecDemo2
{
internal class Program
{
static void Main(string[] args)
{

string userName;
int myNumber;

userName = "Aiden";
myNumber = 890;

decimal rate = 1.23m;


// double is used for decimals unless you are dealing with money.
// then use decimal rate. int and string does not work with decimal numbers

char status = '1';


// char is for single letters or numbers

WriteLine("Enter Your Name");


string name = ReadLine();

WriteLine("Enter Your Faculty");


string faculty = ReadLine();

WriteLine("Enter Your Department");


string department = ReadLine();

//WriteLine("***************************************************************"); //50
//WriteLine("* " + "Name: " + name + " *");
//WriteLine("* " + "Faculty: " + faculty + " *");
//WriteLine("* " + "Department: " + department + " *");
//WriteLine("***************************************************************");

string aLine = new string('*', 64);


WriteLine(aLine);
WriteLine("*{0, 32}: {1, -28}*", "Name ", name);
WriteLine("*{0, 32}: {1, -28}*", "Faculty ", faculty);
WriteLine("*{0, 32}: {1, -28}*", "Department ", department);
WriteLine(aLine);

int number = int.Parse("76"); // as input - string, return


double numberD = double.Parse("56.777");

WriteLine("number = " + number);

Write("Enter Grade1");
int grade1 = int.Parse(ReadLine());
;
// WriteLine is a void return, but a ReadLine can be returned to the string, aka
// must be captured

}
}
}

You might also like