Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners plz check my codings are correct or not...There is an error..i cant find it..
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Thush Perera
plz check my codings are correct or not...There is an error..i cant find it..
1 Answer(s)      3 years and 9 months ago
Posted in : Java Beginners


import java.util.Scanner;
public class Student
{
  private String indexNo;
  private String gender;
  private char initial;
  private int mark1;
  private int mark2;
  private int mark3;
  private int max;

  public Student(String newIndexNo, String newGender, char newInitial, int newMark1, int newMark2, int newMark3)

    {
        indexNo=newIndexNo;
            gender=newGender;
        initial=newInitial;
        mark1=newMark1;
        mark2=newMark2;
        mark3=newMark3;
    }

  public void setIndex(String newIndex)
    {
        indexNo=newIndex;
    }

  public void setGender(String newGender)
    {
        gender=newGender;
    }

  public void setInitial(char newInitial)
    {
        if(newInitial != 'f' || newInitial != 'm')
        initial='m';
    }

  public void setMark1(int newMark1)
    {
        if(newMark1<0 || newMark1>100)
        mark1=0;
    }

  public void setMark2(int newMark2)
    {
        if(newMark2<0 || newMark2>100)
        mark2=0;
    }

  public void setMark3(int newMark3)
    {
        if(newMark3<0 || newMark3>100)
        mark3=0;
    }

  public String getIndex()
    {
        return indexNo;
    }

  public String getGender()
    {
        return gender;
    }

  public char getInitial()
    {
        return initial;
    }

  public int getMark1()
    {
        return mark1;
    }

  public int getMark2()
    {
        return mark2;
    }

  public int getMark3()
    {
        return mark3;
    }




  public void read()
    {
        Scanner text= new Scanner(System.in);
        Scanner num=new Scanner(System.in);

        System.out.print("Enter your index No: ");
        indexNo=text.nextLine();
        System.out.print("Enter your Gender: ");
        gender=text.nextLine();
        initial=gender.charAt(0);
        System.out.print("Enter your mark 1: ");
        mark1=num.nextInt();
        System.out.print("Enter your mark 2: ");
        mark2=num.nextInt();
        System.out.print("Enter your mark 3: ");
        mark3=num.nextInt();
    }

  public void maxMarks()
    {

    if(mark1>mark2 && mark1>mark3)
            max=mark1;
    else
        if(mark2>mark1 && mark2>mark3)
            max=mark2;   
    else
            max=mark3;  

    }


  public void display()
    {
        System.out.printf("%s %c %d %d %d",indexNo,initial,mark1,mark2,mark3);
        System.out.print("          ");
        System.out.printf("Index No %s,You earned %d",indexNo,max);
    }

}//end of class


import java.lang.String;
public class StudentTest
{
  public static void main(String args[])
    {
    Student stu = new Student("AS2010461",'f',"AS2010461",80);
    stu.getIndex();
    stu.getGender();
    stu.getInitial();
    stu.getMark1();
    stu.getMark2();
    stu.getMark3();
    stu.read();
    stu.maxMarks();
    stu.display();
    }
}


import java.util.Scanner;
public class Results
 {
    Scanner kbd=new Scanner(System.in);

    int maxMarks;

        StudentTest stu1=new StudentTest();

        if (maxMarks>90)
            System.out.print("Excellent");
        else if (maxMarks<50)
            System.out.print("Try again");
        else if (maxMarks<=90 && initial='f')
            System.out.print("Good girl");
        else
            System.out.print("Good boy");

public void display1()
      {
        System.out.printf("%s %c %d %d %d",indexNo,initial,mark1,mark2,mark3);
    System.out.print("          ");
    System.out.printf("Index No %s,You earned %d",indexNo,max);
      }
}

Advertisement
View Answers

March 8, 2011 at 5:21 PM


Do modifications in StudentTest.java:

import java.lang.String;
public class StudentTest
{
  public static void main(String args[])
    {
    Student stu = new Student("AS2010461","AS2010461",'f',80,90,100);
    stu.getIndex();
    stu.getGender();
    stu.getInitial();
    stu.getMark1();
    stu.getMark2();
    stu.getMark3();
    stu.read();
    stu.maxMarks();
    stu.display();
    }
}


Related Tutorials/Questions & Answers:
plz check my codings are correct or not...There is an error..i cant find it..
plz check my codings are correct or not...There is an error..i cant find it..  import java.util.Scanner; public class Student { private String indexNo; private String gender; private char initial; private int mark1
plz Help me find the correct programs answers
plz Help me find the correct programs answers   Create a washing...; subtract Create a class called Student which has the following methods: i... INDICA" and "TATA NANO" respectively. Plz mail me your answers
Advertisements
Is this correct???what are the unnessasary codings here??
Is this correct???what are the unnessasary codings here??  import java.util.Scanner; public class Length { public int meters; public int centiMeters; public double yards; public double feet; public double inches
i want to find the byte code of a image file ... for my project..plz if anybody help me for java coding i will grateful..
i want to find the byte code of a image file ... for my project..plz if anybody help me for java coding i will grateful..   i want to convert... project.. but i cant convert Image file to its byte code format.. if anybody can plz
i cant find any compile time error but there is runtime error.
i cant find any compile time error but there is runtime error.  ... stud_code in database. In my case it is Text type. So, I changed the code: int..."); Thanks   Hi, Please check the thread JDBC ODBC error and the specified
this is my code but i cant able to run it wt is the problem
this is my code but i cant able to run it wt is the problem  import java.io.*; class createthread { int thread=4,i; class thread1 extends createthread { public void run() { for(i=0;i
this is my code but i cant able to run it wt is the problem
this is my code but i cant able to run it wt is the problem  import java.io.*; class createthread { int thread=4,i; class thread1 extends createthread { public void run() { for(i=0;i
plz solve my query?
plz solve my query?  how to remove all the options from select control in html using java script?   JavaScript remove all items <...) { var i; for(i=selectbox.options.length-1;i>=0;i--) { selectbox.remove(i
Plz Provide correct program code for all questions.
Plz Provide correct program code for all questions.   Write a program to find the difference between sum of the squares and the square of the sums...: "); int n=input.nextInt(); for(int i=1;i<=n;i++){ int
plz help me find a program
plz help me find a program  plz help..i want a source code in jsp for order processing
Probblems with printing if my innput of text file is correct..
Probblems with printing if my innput of text file is correct..  I am trying to make sure this block of code does what I think it will do. Can someone show me with some code how I can print out what is is labled with <----print
plz anyone can solve my
plz anyone can solve my  creat an applet prog which accepts the details of 10 customers like name , address , city , ect. and display it   import java.awt.*; import javax.swing.*; import java.awt.event.*; import
I didn't gat an output for this code, plz send me a correct code
I didn't gat an output for this code, plz send me a correct code  Hi, Here is my code: import java.awt.event.*; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import javax.swing.*; import java.sql.*; public
Is the logic correct to detect IE version..plz let me know
Is the logic correct to detect IE version..plz let me know  <html> <head> <script type="text/javascript"> function checkIEVersion() { var IE_Version; var IE_Engine; /*@cc_on @if( @_jscript_version
plz. answer my ques - Java Beginners
plz. answer my ques  I want to ask a prog. prob which would create... in which u want to do i mean for view or it simple console based.  create... with regards Fahid   i mean dont follow the first logic which
How to find latitude and longitude of my Mobile Phone?
How to find latitude and longitude of my Mobile Phone?  Hi, What is the best method to find the latitude and longitude of my current location in my... then you can use any GPS enabled application to find the current latitude
fetch database value to text box based on selected value my code given below pls correct my code
fetch database value to text box based on selected value my code given below pls correct my code  my Code Given below Pls... help me send correct code for me jsp file... <%@page contentType="text/html" pageEncoding
fetch database value to text box based on selected value my code given below pls correct my code
fetch database value to text box based on selected value my code given below pls correct my code  my Code Given below Pls... help me send correct code for me jsp file... <%@page contentType="text/html" pageEncoding
plz try to clear my doubt for shuffling multi-dimensional array
plz try to clear my doubt for shuffling multi-dimensional array  hi...??? plz help me... thanks in advance   Hi Friend, Try the following code... ShuffleMultiDimensionalArray() { for (int i = 0; i < size*size; i++){ list.add(i
sir plz do respond to my problem immediately - Java Beginners
sir plz do respond to my problem immediately  Hello sir... for the progree bar is a separate program. sir i need to put it in my web browser.sir iam... code(sent by you).plz inject that code into my browser code so that it can show
Need someone to check and modify my simple code - Java Beginners
Need someone to check and modify my simple code   How to write a class that contains Variables that hold hourly rate of pay, number of hours worked. Display gross pay, withholding tax, which is 15% and net pay. I have tried
How to find version of Java installed on my computer? - Java Beginners
How to find version of Java installed on my computer?  How to get... with many more new features.How to find version of Java installed on my computer?To find out the version of Java installed on your computer, just type Java
how can i add wirecard option(or button ) at my web page plz tell all steps? View Answers
how can i add wirecard option(or button ) at my web page plz tell all steps? View Answers  how can i add wirecard option(or button ) at my web page plz tell all steps? View Answers
why cant i close this ??
why cant i close this ??  import java.util.Scanner; public class square { public static void main ( String [] args) { Scanner keyboard...("Thank you "); } } i should use while to get the square of the number entered
plz give me program to this: Given a string and a number ‘n’, find the ‘n’th distinct repeating character.
plz give me program to this: Given a string and a number ?n?, find the ?n?th distinct repeating character.    Given a string and a number ?n?, find the ?n?th distinct repeating character. For example, Input: Abracadabra, 1
**Connectivity is not getting done in this program plz check it out wat is the problem with that Although i've made tables in MA-ACCESS**
**Connectivity is not getting done in this program plz check it out wat is the problem with that Although i've made tables in MA-ACCESS**  <p>import java.io.*; import java.awt.*; import java.awt.event.*; import
check
updated"); will the above code check if the user has entered value for empcode
please check my code is wrong or ok.it was not work .this is form validation in javascript using jsf page
please check my code is wrong or ok.it was not work .this is form validation in javascript using jsf page  <p>?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN
cant call cmd from java - Java Beginners
cant call cmd from java   How can I call this from java to be executed by cmd ? ConvertXLS.EXE /S "C:\Extracto\*.CSV"/T "C:\Extracto\*.XLS" /C-4143 /F6 /M2 /R /V
plz give me answer plz
plz give me answer plz  writw a programme to find rank from an array using doubledimmensionalarray
I cant get values in MS acces in tables
I cant get values in MS acces in tables   I got problem in sending values from servlet . * i am using ms acces * i cant display my values but der is increase in number of rows my jsp: <%@ page language="java
Advertisements
 

 

 

DMCA.com