0% found this document useful (0 votes)
8 views2 pages

Program 6

The Java program takes student names and their marks in physics and mathematics, calculates their final results based on defined weightage for different assessments, and categorizes them into grades. It demonstrates implicit and explicit type casting, as well as the use of static and dynamic arrays. The program outputs whether each student has passed or failed based on their final results.

Uploaded by

thalamovie234
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Program 6

The Java program takes student names and their marks in physics and mathematics, calculates their final results based on defined weightage for different assessments, and categorizes them into grades. It demonstrates implicit and explicit type casting, as well as the use of static and dynamic arrays. The program outputs whether each student has passed or failed based on their final results.

Uploaded by

thalamovie234
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

import [Link].

Scanner;

public class program6 {


public static void main(String[] args) {
// [Link] input in various datatypes and then perform implicit
// and explicit type casting
// [Link] and define array static and dynamic arrays in java
// 3. Creating strings and declaring them , userdefined string

Scanner sc = new Scanner([Link]);


// 1.

// // int,char,float,double,String...
// int a = 123;
// int scanned_int= [Link]();
// char scanned_char = [Link]().charAt(0);
// char ch = 'A';
// float fl = 10.10f;
// double d = 10.10;

// int e = fl;
// int b = (int)fl;
// float c = b;

// // 2.
// int[] static_array = new int[] {1,2,3};
// String[] static_String = new String[]{"abc","def"};
// char[] static_char = new char[]{'a','b','c'};

// int size_of_userdefined_array = [Link]();


// int[] userdefined_array = new int[size_of_userdefined_array];

// for(int i=0;i<size_of_userdefined_array;i++)
// userdefined_array[i] = [Link]();

// // [Link]

// String str1 = "JAVA";


// String str2 = new String("JAVA");
// String str3 = [Link]();

//4. Create a profile of student which has attributes like


// create an array
// university name, student name, ia1, ia2, mte, ete ,
// total marks of subject = ete*0.5 + mte*0.25 + (ia1+ia2)*0.25;

int[] physics_array = new int[4];


int[] maths_array = new int[4];
String results[] = new String[5];
String names[] = new String[5];
for(int i=0;i<5;i++)
{
[Link]("Enter student"+i+"name : ");
names[i] = [Link]();
[Link]("Enter physics marks of Student: "+i +" in
ia1,ia2,mte,ete");
for(int j=0;j<4;j++)
physics_array[j] = [Link]();
[Link]("Enter maths marks of Student: "+i +" in
ia1,ia2,mte,ete");
for(int j=0;j<4;j++)
maths_array[j] = [Link]();
double result_phy = (physics_array[0]+physics_array[1])*0.25 +
(physics_array[2]*0.25+physics_array[3]*0.5);
double result_math = (maths_array[0]+maths_array[1])*0.25 +
(maths_array[2]*0.25+maths_array[3]*0.5);

double final_result = (result_phy + result_math)/2;


if(final_result >= 80)
results[i] = "Distinction";
else if(final_result >= 70)
results[i] = "First class";
else if(final_result >= 60)
results[i] = "second class";
else results[i] = "fail";
}

for(int i=0;i<5;i++)
{
if(results[i] == "fail")
[Link](names[i]+" has failed");
else
[Link](names[i]+" has passed in "+results[i] );
}

[Link]();

}
}

You might also like