Share on Google+Share on Google+

purple_coat
explaination
1 Answer(s)      5 years and 5 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

} }

Ads

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
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
Advertisements
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
Tutorials   
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code

Ads

 
Advertisement null

Ads