हिंदी

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

प्रश्न

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. 

संक्षेप में उत्तर
Advertisements

उत्तर

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
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 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. 10. | पृष्ठ २४१
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×