Question

3) Write an algorithm to take a list of numbers from user and determine the numbers...

3) Write an algorithm to take a list of numbers from user and determine the numbers divisible by the number 7. You need to first prompt the user that how many numbers s/he wants to input and then take the numbers. After taking the numbers, you check which numbers are divisible by 7 from the list. You need to print the number along with the position of the number. Finally, you need to print how many numbers from the list is divisible by 7. If there is no number divisible by 7 then print the message "Sorry, the list doesn’t contain any number divisible by 7".

Input: How many numbers to input? 5 22 21 15 78 49

Output:

Number: 21

Position: 2

Number: 49

Position: 5

Numbers divisible by 7 is: 2

Homework Answers

Answer #1

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

  • Function isDivisible(n)
    • If n%7==0
      • RETURN TRUE
    • ELSE
      • RETURN FALSE
    • EndIF
  • ENDFUNCTION
  • Function Main()
    • PRINT "How many numbers to input? "
    • Get input n
    • Define an array with n numbers
    • GetInput n numbers and fill them in array
    • Declare and initialize a count to 0
    • For i =0 to n-1 do
      • if(isDivisible(arr[i]))
        • PRINT "Number: "+arr[i];
        • PRINT "Position: "+(i+1)
        • count++;
      • EndIf
      • If(count==0)
        • PRINT "Sorry, the list doesn’t contain any number divisible by 7";
      • Else
        • PRINT "Numbers divisible by 7 is: "+COUNT
      • EndIf
    • EndLoop
  • EndFunction

Kindly revert for any queries

Thanks.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
4) Write an algorithm to take a list of numbers from user and determine the grade...
4) Write an algorithm to take a list of numbers from user and determine the grade for CSCI1320 students. You need to first prompt the user to know how many students are in the class and then take the final scores in a list. After taking the scores, you check which grade the student has got based on the input score stored in the list. If the score is between or 90 and 100 then it’s an ‘A’ grade, if...
Write an application that prompt user to choose Sorting Algorithm (Insertion, Merge, or Heap) in GUI...
Write an application that prompt user to choose Sorting Algorithm (Insertion, Merge, or Heap) in GUI input message, then prompt user to enter numbers in GUI input message also, sort these numbers in descending order using Selected sorting algorithm, and show the result in message dialog as shown in the following figure. The program contains two classes: 1- “Sort” Class which contains 3 methods named as follow: a. InsertionSort(int[] numbers), returns sorted numbers from the passed array using Insertion sort...
Please use Python 3 4). Write a program that asks the user to enter 10 numbers....
Please use Python 3 4). Write a program that asks the user to enter 10 numbers. The program should store the numbers in a list and then display the following data: • The lowest number in the list • The highest number in the list •The total of the numbers in the list • The average of the numbers in the list   Sample input & output: (Prompt) Enter Number 1: (User enter) 4 (Prompt) Enter Number 2: (User enter) 7...
This program is for kindergartners to practice knowledge on numbers divisible by 5. Write a code...
This program is for kindergartners to practice knowledge on numbers divisible by 5. Write a code using a while loop, which keeps asking the user to enter an number divisible by 5. The program(i.e the while loop) terminates when the user enters a number divisible by 5, but keeps running if the user fails to enter a number divisible by 5. Also print appropriate message after each failed try. When successful, tell the user how many attempts were needed for...
C++ Goals:Practicing arrays Create a program that will read whole numbers from a file called Labs4-7Mu.dat...
C++ Goals:Practicing arrays Create a program that will read whole numbers from a file called Labs4-7Mu.dat (posted on Canvas)and store it into an array. The number of values in the file is less than 300 and all the values are whole numbers. The actual number of values stored in the file should be determined. Your program should then prompt the user to enter another whole number between 2 and 20 (you may assume the user enters a valid value) and...
JAVA Write an application that will input four positive integers from the user. The program should...
JAVA Write an application that will input four positive integers from the user. The program should print out the largest and smallest number. It should print how many of the numbers are even and how many are odd. It should print how many of the numbers are one digit and how many of the numbers are two digit. It should print out the sum of all even numbers and the sum of all odd numbers. It should print out the...
Given 3 numbers T, r and s, where r != s and r > 1 &...
Given 3 numbers T, r and s, where r != s and r > 1 & s > 1. Print a list of numbers from 1 to T where numbers divisible by r whose decimal representation does not contain the digit r should be replaced by the number 555 and any number (int) divisible by s whose decimal representation does not contain the number s should be replaced by the number 333. Numbers for which both of the past arguments...
draw flowchart of: 1-algorithm that asks the user to enter three numbers and computes and prints...
draw flowchart of: 1-algorithm that asks the user to enter three numbers and computes and prints out the largest number. 2- an algorithm that asks the for an integer N from the user. The algorithm should find whether the number is positive, negative, or ZERO. 3-an algorithm that asks the user to enter a positive integer N. You then need to calculate the sum of all values from 1 to N.
In this programming exercise you will create an algorithm for solving the following version of the...
In this programming exercise you will create an algorithm for solving the following version of the m Smallest Numbers problem.   Instead of just returning the m smallest values as in homework 1, you want to return a list of the positions where the m smallest values are located without changing the original array. Your algorithm should meet the following specifications: mSmallest( L[1..n], m ) Pre: L is a list of distinct integer values. n is the number of elements in...
 Write a program to find the prime numbers - Ask user to input the integer...
 Write a program to find the prime numbers - Ask user to input the integer number - test the number whether it is a prime number or not - Then, print “true” or “false” depending on whether the number is prime or isn’t. - Hint: number is prime when is has exactly 2 factors: one and itself. By this definition, number 1 is a special case and is NOT a prime. - Use idea of user input, cumulative sum,...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT