Computer science

Question Description

Write a program that uses a loop to count to 4

You should turn in a brief report by the end of class.

Your report should include:
• 5 points: Your name
• 20 points:A single question describing what the question is asking
• 30 points:Your code
• 10 points:Your code output
• 10 points:A discussion of your solution

using System;

public class Program
{
public static void Main()
{
Console.WriteLine(“Whaddup World”);
int count = 0;
while(4 >= count){
Console.WriteLine(count);
count++;
}
for (int loopCount = 0; loopCount <=4; loopCount++){
Console.WriteLine(loopCount);
}
}
}

and

import java.util.Scanner;

public class LoopTutorial {

public static void main(String[] args) {
// TODO Auto-generated method stub

Scanner userInput = new Scanner(System.in);
boolean terminationCondition = false;

while (!terminationCondition) {
System.out.println(“Choose an option!n”
+ “1 for Say Hellon”
+ “2 for count to 4n”
+ “3 for close programn”);
int userDecision = userInput.nextInt();
switch (userDecision) {
case 1:
System.out.println(“Hello”);
break;
case 2:
for (int i = 0; i <= 4; i++) {
System.out.println(i);
}
break;
case 3:
terminationCondition = true;
break;
default:
System.out.println(“Not a valid command”);
break;
}
}//closes while loop
System.out.println(“Goodbye!”);
}

}

Get your college paper done by experts

Do my question How much will it cost?

Place an order in 3 easy steps. Takes less than 5 mins.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *