Question
Somebody know how to summarize the error's names? Look at each of the descriptions below and identify the type of programming error . Note that
Somebody know how to summarize the error's names?
Look at each of the descriptions below and identify the type of programming error. Note that more than one of these descriptions may be caused by the same type of programming error.
2 points: You calculate the average of a list of grades with the expression:
average = sum / size; // assume average is double and sum & size are ints
However, average is always a whole number because sum and size are both integers.
What kind of error is this?
2 points: You forget to put an ending double quote in a System.out.println() statement:
System.out.println("Hello there! );
What kind of error is this?
2 points: You write a loop to that counts down to zero but sometimes it runs forever:
int number = input.nextInt();
int sum = 0;
System.out.println("Countdown to zero!");
while (number != 0)
{
System.out.print(number + " ");
sum += number;
number--;
}
System.out.println();
System.out.println("The sum of the numbers is: " + sum);
What will cause the loop to run forever? What kind of error is this?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started