Share on Google+Share on Google+

1 Answer(s)      5 years and 6 months ago
Posted in : Java Beginners

can you give me the explaination of this coding.

import java.util.*;

public class StudentMarks{

double totalMarks; String grade;

public void setTotalMarks(double totalMarks){ this.totalMarks=totalMarks; } public double getTotalMarks(){ return totalMarks; } public void setGrade(String grade){ this.grade=grade; } public String getGrade(){ return grade; } public static void main(String[]args){ Scanner input=new Scanner(System.in); System.out.print("Enter number of students: "); int num=input.nextInt(); StudentMarks data[]=new StudentMarks[num]; for (int i=0; i=40&&marks<=50){ data[i].setGrade("E"); } if(marks>50&&marks<=59){ data[i].setGrade("D"); } if(marks>60&&marks<=70){ data[i].setGrade("C"); } if(marks>70&&marks<=85){ data[i].setGrade("B"); } if(marks>85&&marks<=95){ data[i].setGrade("A"); } if(marks>95){ data[i].setGrade("A+"); }

} int count1=0,count2=0,count3=0,count4=0; for(int i=0;i

} }

View Answers

October 27, 2011 at 10:52 AM

In the code, the user is allowed to enter the number of students appearing for the exams and enter their marks one by one. These marks is then checked for the grade. There is an scale to get the grade according to that scale. The grades is to be stored for the particular marks with setGrade() method. The four counters is initialized in order to count the number of students getting A, A+, D and E grade. To count the number of students getting A and A+, the counter values of A and A+ is added. Similarly, the counter values of D and E is added in order to find out the number of students getting A and E marks simultaneously.


Related Tutorials/Questions & Answers:
explaination  can you give me the explaination of this coding. import java.util.*; public class StudentMarks{ double totalMarks; String grade; public void setTotalMarks(double totalMarks){ this.totalMarks=totalMarks; } public
Object class in java
Object class in java  want an example and with an explaination about equals() method in object class? Is equals() is similar
Exception Handlerin java..
Exception Handlerin java..  can a catch block accept multiple argument and return type?? please tell with explaination
How to Develop, Compile & Run a rmi Program in NetBeans 6.9.1 ide?
How to Develop, Compile & Run a rmi Program in NetBeans 6.9.1 ide?  how to develop, compile & run a rmi program in netbeans 6.9.1 ide? will you please give me a step by step (practical) explaination? Thanks in advance
solve this pbm
solve this pbm  sir rows are also inserting i have checked in the database also the rows are not affected in the table . The first pbm wich i have sent to you is not yet solved.......... pls give me detail explaination how we
log4j in web application
log4j in web application  Hi all, I am new to log4j. I want to use log4j in my web application. I need to write the debug,info,warn into a file. But i don't know how to do the same. Please send one example with explaination
Struts - Struts
Struts  Is Action class is thread safe in struts? if yes, how it is thread safe? if no, how to make it thread safe? Please give me with good explaination and example? thanks in advance.  Hi Friend, It is not thread
This is what i need in this Question - Java Beginners
explaination with out coding In my understanding I choose the non-empty array
appfuse tool - Ant
application war file to me. With explaination coding details sir.i have
Create Dynamic Table using Hubernate
Create Dynamic Table using Hubernate  Thank's for reading my Post. I am new to hibernate.all i need some clarification and explaination. Problem 1: How to create seperate table for all users they sign up for my web app. i need
Please Help - JSP-Servlet
the procedure for how to bring my alert box in Home Page? Theoretical explaination
Java - JSP-Servlet
Java  Respected sir/Madam, Thanks for your response.. This is a general question. How to compile a servlet program? I need step by step explaination.. MoreOver,I know JAVA to some extent.. But I need to improve my
java - Development process
with explaination and full code of the program Account.java:36: cannot find symbol symbol...(); ^ 6 errors Sir please give full code with explaination that how
jQuery autocomplete with jsonp
this},fa:c}}("#ac_q"); (function(a){a.fn.U=function(b){var c=this;b=a.extend...); thanks for further help  More explaination: I really donīt know
Java Spring Hibernate Struts Training java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient How do I resolve this Java Class not found exception? httpclient java.lang.NoClassDefFoundError Apache Commons ioutils maven dependency Read/Convert an inputStream to a String What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history Best Reasons to learn Java Java Example Codes and Tutorials in 2017 How do I read a large file quickly in Java? Is learning Java worthwhile?


Advertisement null