Computer Science, asked by motherachanareddy, 19 days ago

'Perfect Math' is an online math program. In one of the assignments the system displays a list of N numbers and a value K, and students need to calculate the sum of remainders after dividing all the numbers from the list of N numbers 17 18 19 20- 21 22 23 by K. The system needs to develop a program to calculate the correct answer for the assignment. sulate the

Answers

Answered by samarthkrv
4

Answer:

import java.util.*;

public class perfectMath

{

public static void main(String[] args) {

 ArrayList<Integer> list = new ArrayList<Integer>();

 Scanner sc = new Scanner(System.in);

 System.out.print("Enter value for k:");

 int k = sc.nextInt();

 for(int i = 17; i <= 23; i++){

     list.add(i);

 }

 int remsum = 0;

 for(int i = 0; i < list.size(); i++){

     int rem = list.get(i) % k;

     remsum = remsum + rem;

 }

 System.out.println("the sum of remainders of all numbers divided by k is " + remsum);

}

}

Explanation:

Similar questions