Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java programing. please do all 3 * Testscores.java * Dean & Dean * This implements an algorithm that averages test scores. import java.uti1. Scanner: public

java programing. please do all 3
image text in transcribed
image text in transcribed
* Testscores.java * Dean \& Dean * This implements an algorithm that averages test scores. import java.uti1. Scanner: public class Testscores C public static void main(String[] args) [ Scanner stdIn - new Scanner(System. in): int score: int scoresum = 0 int count - 0 : double average - 0 : System,out. print("Enter score (-1 to quit): "): score - stdIn.hextInt(): while ( score >0) C scoresum += score: count+i; average - (double) scoresum / count: System.out, print("Enter score (1 to quit): ") : score - stdin.nextlnt( ) : 3 System, out, println("Average score is " + average): J Il end main J II end Testscores class In the above program, note how the following lines appear above the loop and Page 167 also at the bottom of the loop: System.out. print( "Enter score (-1 to quit): -): score - stdin.nextint () : Modify the program so it avoids having those lines appear twice but keeps the same functionality. For your modification, you are required to use a boolean variable named done in the while loop's condition. 10. [after 4.13] Consider the following code fragment. Without changing the loop type, modify the code to prevent output when the input equals the sentinel value of zero. Scanner stdin - new Scanner (System. in): int x : do c x stdin, nextint () : System,out.printin("negative "+(x)); while (x0) : 11. [after 4.15] Here's a brain teaser that uses Boolean logic: You're traveling on a road, and you come to a fork in the road. You know that one path leads to a pot of gold and the other path leads to a dragon. There are two elves at the fork, both of whom know the way to the pot of gold. You know that one elf always tells the truth and the other elf always lies, but you don't know which elf is which. What single question should you ask to figure out the proper path to the pot of gold

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions