C# Programming Quiz
//Check user hasn't entered incorrect value.
if (!(rerunProgram == "Y" || rerunProgram == "N"))
{
Console.WriteLine("You have not typed Y or N!");
wrongUserValue = true;
}
//Check user hasn't entered incorrect value.
if (rerunProgram != "Y" || rerunProgram != "N")
{
Console.WriteLine("You have not typed Y or N!");
wrongUserValue = true;
}
//Check user hasn't entered incorrect value.
if (!(rerunProgram != "Y" || rerunProgram != "N"))
{
Console.WriteLine("You have not typed Y or N!");
wrongUserValue = true;
}
//Check user hasn't entered incorrect value.
if (rerunProgram == "Y" || rerunProgram == "N")
{
Console.WriteLine("You have not typed Y or N!");
wrongUserValue = true;
}
//Check user hasn't entered incorrect value.
if (rerunProgram == "Y" && rerunProgram == "N")
{
Console.WriteLine("You have not typed Y or N!");
wrongUserValue = true;
}
Write a program to accept a number from a user, calculate the number doubled, and return the doubled number to the user.
Input |
Process |
Output |
double number |
Prompt and get number from user Calculate number doubled Display doubled number |
number |
Input |
Process |
Output |
Prompt and get number from user Calculate number doubled Display doubled number |
number |
double number |
Input |
Process |
Output |
double number |
Prompt and get number from user Calculate number doubled Display doubled number |
number |
Input |
Process |
Output |
number |
Prompt and get number from user Calculate number doubled Display doubled number |
double number |
Input |
Process |
Output |
number |
Prompt and get number from user Calculate number doubled double number |
Display doubled number
|
static void Main(string[] args)
{
userNumber = int.Parse(Console.ReadLine());
doubleUserNumber = userNumber * 2;
Console.WriteLine(doubleUserNumber);
Console.ReadLine();
}
static void Main(string[] args)
{
userNumber = int.Parse(Console.ReadLine());
doubleUserNumber = userNumber * 2;
Console.WriteLine(userNumber);
Console.ReadLine();
}
BEGIN DOUBLE-PROGRAM
prompt user for number
get number from user
calculate doubleTheNumber = number * 2
display doubleTheNumber
END DOUBLE-PROGRAM
{
userNumber = int.Parse(Console.ReadLine());
doubleUserNumber = userNumber * 2;
Console.WriteLine("This is not real code. It is Psuedo Code.");
}
BEGIN DOUBLE-PROGRAM
prompt user for number
get number from user
calculate doubleTheNumber = number * 2
display user's chosen number.
END DOUBLE-PROGRAM
static void Main(string[] args)
{
userNumber = int.Parse(Console.ReadLine());
Console.WriteLine(userNumber);
Console.ReadLine();
}
static void Main(string[] args)
{
if (showFormYesNo = true)
{
showForm();
}
}
public static int number2 = 5;
static void Main(string[] args)
{
number1 /= number2;
Console.WriteLine(number1);
Console.ReadLine();
}
public static int number2 = 4;
static void Main(string[] args)
{
number1 *= number2;
Console.WriteLine(number1);
Console.ReadLine();
}
public static int number2 = 10;
static void Main(string[] args)
{
number1 += number2;
Console.WriteLine(number1);
Console.ReadLine();
}
public static int number2 = 75;
static void Main(string[] args)
{
number1 -= number2;
Console.WriteLine(number1);
Console.ReadLine();
}
public static int number2 = 75;
static void Main(string[] args)
{
number1 = number2;
Console.WriteLine(number1);
Console.ReadLine();
}
{
case 1:
DisplayReport(1);
break;
case 2:
DisplayReport(2);
break;
case 3:
DisplayReport(3);
break;
case 4:
DisplayReport(4);
break;
default:
Console.WriteLine("There was an error. Reporting this to the developer.");
ReportErrorMessage();
break;
}
{
case 1:
DisplayReport(1);
break;
case 2:
DisplayReport(2);
break;
case 3:
DisplayReport(3);
break;
case 4:
DisplayReport(4);
break;
default:
Console.WriteLine("There was an error. Reporting this to the developer.");
ReportErrorMessage();
break;
}
//Check user hasn't entered incorrect value.
if (rerunProgram == "Y" || rerunProgram == "N")
{
Console.WriteLine("You have not typed Y or N!");
wrongUserValue = true;
}
display "Larger than 10"
IF number > 20 THEN
display "larger than 20"
ELSE
display "smaller than 20"
ENDIF
ELSE
display "Smaller than 11"
IF number < 0 THEN
display "Negative number"
ENDIF
ENDIF
return ThisMethod(value);
is contained in a method with the following header:
public static int ThisMethod(int value)
What is the name given to this sort of method?
StreamWriter outFile = new StreamWriter(fileName);