English

To get promotion in a Science stream, a student must pass in English and should pass in any of the two subjects (i.e., Physics, Chemistry or Maths). The passing mark in each subject is 35.

Advertisements
Advertisements

Question

To get promotion in a Science stream, a student must pass in English and should pass in any of the two subjects (i.e., Physics, Chemistry or Maths). The passing mark in each subject is 35. Write a program in a Single Dimensional Array to accept the roll numbers and marks secured in the subjects for all the students. The program should check and display the roll numbers along with a message whether "Promotion is Granted" or "Promotion is not Granted". Assume that there are 40 students in the class. 

Answer in Brief
Advertisements

Solution

import java.util.*;
class Q10{
public static void main(String args[]){
Scanner ob = new Scanner(System.in);

int i, roll[] = new int[40]; // FOR TESTING PURPOSE,CHANGE 40 TO 3
double e[] = new double[40]; // ENGLISH
double m[] = new double[40]; // MATHS
double p[] = new double[40]; // PHYSICS
double c[] = new double[40]; // CHEMISTRY
boolean flag;

// INPUT LOOP
for (i = 0; i < roll.length; i++)
{ 
System.out.print("Roll number: ");
roll[i] = ob.nextInt();
System.out.print("Enter marks in Eng, Maths, Phy and Chem \n");
e[i] = ob.nextDouble();
m[i] = ob.nextDouble();
p[i] = ob.nextDouble();
c[i] = ob.nextDouble();
}

// OUTPUT LOOP
System.out.println("ROLL NO. \t RESULT");
for (i = 0; i < roll.length; i++)
{ if ((m[i] >= 35 && p[i] >= 35) || (p[i] >= 35 && c[i] >= 35) || (m[i] >= 35 && c[i] >= 35))
flag = true;
else
flag = false; 

if (flag == true && e[i] >= 35)
System.out.printIn(roll[i] + "\t Promotion is granted");
   else
System.out.printIn(roll[i] + "\t Promotion is not granted");
}
}}
shaalaa.com
  Is there an error in this question or solution?
Chapter 3: Arrays (Single Dimensional and Double Dimensional) - EXERCISES [Page 241]

APPEARS IN

Avichal Computer Applications [English] Class 10 ICSE
Chapter 3 Arrays (Single Dimensional and Double Dimensional)
EXERCISES | Q VII. 10. | Page 241
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×