In: Computer Science
Find the Bug - Looking for at least 3 bugs! USE SOME METHOD TO SHOW ME YOUR "FIXED CODE" ( type it in Red or highlight in yellow or use // at the end of the line) Your downloadable files for Chapter 1 include DEBUG02-01 Each file starts with some comments ( lines that begin with two slashes ) that describe the program. Examine the pseudocode that follows the introductory comment, then find and correct all the bugs. Click here for Debug0201.docxPreview the document Complete your answer in Word, Save it, and upload it into the assignment.
Debug0201
// This pseudocode segment is intended to compute and display
// the average grade of three tests
start
Declarations
num test1
num test2
num test2
num average
output "Enter score for test 1 "
input test1
output "Enter score for test 2 "
input test2
output "Enter score for test 3 "
input test3
average = test1 + test2 + test3 / 3
output "Average is ", answer
end
Here is the answer...
// This pseudocode segment is intended to compute and display
// the average grade of three tests
start
Declarations
num test1
num test2
num test3
double average //it should be double or float
output "Enter score for test 1 "
input test1
output "Enter score for test 2 "
input test2
output "Enter score for test 3 "
input test3
average = ( test1 + test2 + test3 ) / 3
output "Average is ", average
end
Sample CODE and OUTPUT:
import java.util.*;
class Average
{
public static void main(String[] args) {
Scanner sc=new
Scanner(System.in);
int test1;
int test2;
int test3;
double average;
System.out.println("Enter score
for test 1");
test1 = sc.nextInt();
System.out.println("Enter score
for test 2");
test2 = sc.nextInt();
System.out.println("Enter score
for test 3");
test3 = sc.nextInt();
average = (test1 +test2 + test3) / 3;
System.out.println("Average is"+average);
}
}
If you have any doubts please COMMENT..
If you understand the answer please give THUMBS UP..