मराठी

Write a program to accept a name and total marks of N number of students in two single subscript array name[] and totalmarks[]. Calculate and print: i. The average of the total marks obtained by N

Advertisements

प्रश्न

Write a program to accept a name and total marks of N number of students in two single subscript array name[] and totalmarks[].

Calculate and print:

  1. The average of the total marks obtained by N Number of students.
    [average = (sum of total marks of all the students)/N]
  2. Deviation of each student’s total marks with the average
    [deviation = total marks of a student – average] 
थोडक्यात उत्तर
Advertisements

उत्तर १

import java.io.*;
import java. util. Scanner;
class NameMarks {
public static void main(String argsO) throws IOException {
Scanner sc = new Scanner(System.in);
System.out.print(“Enter number of students:”);
int N = sc.nextlnt( );
String named = new String[N];
int totalmarksG = new int[N];
double deviation[ ] = new double[N];
double sum = 0;
for (int i = 0; i < N; i+ +) {
System.out.print(“Enter Name of the Student:”);
name[i] = sc.next( );
System.out.print(“Enter Marks:”);
totalmarks[i] = sc.nextlntO;
sum = sum + totalmarks [i];
}
double average = sum / N;
System.out.println(“The average of the total marks of ” +N+” number of students:” +average);
for (int i = 0; i < N; i+ +) {
deviadon[i] = total marks (i] – average;
System.out.println(“Deviation of” + name[i] + “s marks with the average:” +deviation[i]);
}
}
}

shaalaa.com

उत्तर २

import java.util.*;
public class AQ5
{public static void main(String hh[])
{
Scanner ob = new Scanner(System.in);
int sum = 0, dev;

System.out.printIn("Enter the number of students");
int N = ob.nextInt();
String name[] = new String[N];
int[] tot = new int[N];

for (int i = 0; i < N; i++)
{System.out.println("**Student" + (i + 1) + "**");
System.out.print("Enter the name :");
name[i] = ob.next();
System.out.print("Enter the total :");
tot[i] = ob.nextInt();
sum = sum + tot[i];
}

int avg = sum / N;
System.out.printin("\n\nAverage of total marks of all the students: " + avg);

for (int j = 0; j < N; j++)
{
dev = tot[j] – avg;
System.out.print(name(j]);
System.out.printIn("Deviation = " + dev);
}
}}
shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 3: Arrays (Single Dimensional and Double Dimensional) - EXERCISES [पृष्ठ २४०]

APPEARS IN

अविचल Computer Applications [English] Class 10 ICSE
पाठ 3 Arrays (Single Dimensional and Double Dimensional)
EXERCISES | Q VII. 5. | पृष्ठ २४०
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×