Concept explainers
The programmer intended the following pseudocode to get five sets of two numbers each, calculate the sum of each set, and calculate the sum of all the numbers entered. It will not function as intended, however. Find the error.
// This
Declare Integer number, sum, total
Declare Integer sets, numbers
Constant Integer MAX_SETS = 5
Constant Integer MAX_NUMBERS = 2
Set sum = 0;
Set total = 0;
For sets = 1 To MAX_NUMBERS
For numbers = 1 To MAX_SETS
Display "Enter number ", numbers, " of set ", sets, "."
Input number ;
Set sum = sum + number
End For
Display "The sum of set " sets, " is , sum, "."
Set total = total + sum
Set sum = 0
End For
Display "The total of all the sets is total , "."
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Starting Out with Programming Logic and Design (4th Edition)
Additional Engineering Textbook Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Concepts of Programming Languages (11th Edition)
Starting Out With Visual Basic (7th Edition)
Database Concepts (8th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
- The program segment has errors. Find as many as you can. // This code should display the sum of two numbers. int choice, num1, num2; do {cout << "Enter a number: "; cin >> num1;cout << "Enter another number: "; cin >> num2;cout << "Their sum is " << (num1 + num2) << endl;cout << "Do you want to do this again?\n";cout << "1 = yes, 0 = no\n"; cin >> choice;} while (choice = 1)arrow_forwardC programringarrow_forwardThe following program or program segment has errors. Find as many as you can. char numeric[5]; int x = 123; numeric = atoi(x);arrow_forward
- Refer to the following code. Which line may be used to complete the code so it would not result to an error? count = 15 while count > 5: print (count) A none of these; the code is complete by itself (B) count == count (C) count = count - 4 (D) count += 1arrow_forwardRacket code only please - primeTest It takes as input any positive integer n and returns true if the absolute value of the polynomial 8n2 − 488n + 7243 is a prime number. For example, the invocation (primeTest 5) should return true. - primeTestSeq This takes two arguments, a low bound and an upper bound. It determines what percentage of the integers between the lower bound and the upperbound are, according to primeTest, a prime number. For example, the invocation (primeTestSeq 1 60) should return 100.arrow_forwarddef division_calculator(a, b): ''' Question 4 You are asked to write a small division calculator, where you are taking 'a' as dividend and 'b' as the divider. You will need to return both the quotient and the remainder. Your returned result should be the: "a is divided by b, with the quotient equals 'quotient' and remainder equals 'remainder'" Note: You must use f-string to do this question. Args: a (int), b (int) Returns: string >>> division_calculator(3, 1) "3 is divided by 1, with the quotient equals 3 and remainder equals 0." ''' # print(division_calculator(9, 3))arrow_forward
- Nice Number Programming: Nice program ask user to enter three integers from keyboard (java console), the three integers represent left bound, right bound and arbitrary digit 'm', where left bound is less than right bound. Program should print all nice numbers in the given range that doesn't contain digit 'm'. The number is nice if its every digit is larger than the sum of digits which are on the right side of that digit. For example 741 is a nice number since 4> 1, and 7> 4+1. with digit m=2. Write a complete program in Java that Call only One method (niceNumbers method) that will print all nice numbers excluding a given digit 'm' that also entered by user?arrow_forwardfunction triangular_number() { echo "Enter the range of numbers (start end): " read start end even_count=0 odd_count=0 echo "------------------------------------------" for (( i=$start; $i<=$end; i++ )) do triangular=$(( (i*(i+1))/2 )) if [[ $triangular -gt $start && $triangular -lt $end && $((triangular%2)) -eq 0 ]]; then ((even_count++)) echo $triangular elif [[ $triangular -gt $stat && $triangular -lt $end ]]; then ((odd_count++)) fi done echo "------------------------------------------" echo "Total even triangular numbers found: $even_count" echo "Total odd triangular numbers found: $odd_count" } Make a flowchart with this code No hand written and fast answer with explanationarrow_forwardpython simple codearrow_forward
- Please draw the correct flowchart for this game ? # Function to display question and answer def new_game(): guesses = [] Right_guesses = 0 question_num = 1 num = 1 for key in questions: print("\n------------------------- \n") print("Question " + str(num) + "\n" ) num += 1 print(key) for i in options[question_num-1]: print(i) guess = input("\nAnswer (A, B, C, or D): ") guess = guess.upper() guesses.append(guess) Right_guesses += check_answer(questions.get(key), guess) question_num += 1 display_score(Right_guesses, guesses) # ------------------------- # Function to check answer def check_answer(answer, guess): if answer == guess: print("\nYour Answer Correct!") return 1 else: print("\nYour Answer Wrong!") return 0 # ------------------------- # Function to display score def display_score(Right_guesses, guesses):…arrow_forwardFibonacci sequence: The first two numbers of the fibonacci sequence are 1 and 1, and sequential numbers are the sum of the previous two. Write a program that prompts the user for an integer n and then prints the first n numbers of the Fibonacci sequence (Please type answer no write by hend)arrow_forwardC#: Please helparrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage