Page 130 - CA_Blue( J )_Class9
P. 130
Program 7 Write a program to input the name of a student, section and roll number. Also input the
marks of two subjects in byte data type and print the sum in short data type and average in
float data type. (The program should be written using the InputStreamReader class)
1 import java.io.*;
2 class inputstreamreader
3 {
4 public static void main()throws IOException
5 {
6 InputStreamReader isr= new InputStreamReader(System.in);
BufferedReader br= new BufferedReader(isr);
7
String name;
8
9 char sec;
10 int roll;
11 byte m1,m2;
12 short sum;
13 float avg;
System.out.print("Enter name of the student : ");
14
name=br.readLine();
15
16 System.out.print("Enter section : ");
17 sec=br.readLine().charAt(0);
18 System.out.print("Enter Roll number : ");
19 roll=Integer.parseInt(br.readLine());
System.out.print("Enter Computer Marks : ");
20
m1=Byte.parseByte(br.readLine());
21
22 System.out.print("Enter Physics Marks : ");
23 m2=Byte.parseByte(br.readLine());
24 sum=(short)(m1 + m2);
25 avg=(float)(sum/2.0);
System.out.println("------Result of the student-------");
26
System.out.println("Name\tSection\tRoll");
27
28 System.out.println(name +"\t"+ sec +"\t"+ roll);
29 System.out.println("-----MARKS OF SUBJECTS-----");
30 System.out.println("Computer\tPhysics ");
31 System.out.println(m1+"\t\t"+m2);
32 System.out.println("Total\tAverage ");
128 Touchpad Computer Applications-IX

