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

 
 


Thush Perera
plz check my codings are correct or not...There is an error..i cant find it..
1 Answer(s)      2 years and 2 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);
      }
}
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 Pages:
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
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
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
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
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
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
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 help me find a program
plz help me find a program  plz help..i want a source code in jsp for order processing
How to get the correct value by calculating double values....
duration 59 i am getting wrong cost .. Sir plz help me in this code.Thank you Sir...How to get the correct value by calculating double values....  Hello Sir, I have a method in which i am getting getting wrong
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
How to get the correct value by calculating double values....
duration 59 i am getting wrong cost .. Sir plz help me in this code.Thank you Sir...How to get the correct value by calculating double values....  Hello Sir, I have a method in which i am getting getting wrong
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
check where is error - JSP-Interview Questions
check where is error  hi deepak i have made a program in javascript but it is not working properly will u plz tell me where is error in my program..."); } } function reverse(ss) { var len=ss.length; var rev=" "; for(var i=len
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
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
find the first character is vowel or not
find the first character is vowel or not  hi friend, can u plz send me javascript code for find the wether the first character is a vowel or not. 2) check wether the last character is same as the first character or not 3) check
plz give me answer plz
plz give me answer plz  writw a programme to find rank from an array using doubledimmensionalarray
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
Doclets Find Bad Code - Java Tutorials & Doclets Tutorial
this newsletter out as regularly as I would like to. My excuse is rather lame - I'm busy...Doclets Find Bad Code 2001-11-17 The Java Specialists' Newsletter [Issue 035] - Doclets Find Bad Code Author: Dr. Heinz M. Kabutz If you are reading
check box realtive information in page store in database
check box realtive information in page store in database  check box relative information in page store in database  hiiiiiiiii, Que I create a checkbox in html and when i click on my check box realtive information
ANZ PLZ
ANZ PLZ  Discuss String class METHODS   Please visit the following link: String Methods Here you will find the examples related to the methods of String class
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
ANZ PLZ
ANZ PLZ  FIND DISCRIPTION ABOUT print () and println ()METHODS   Both methods belongs to the PRINTSTREAM class in Java The Print() method prints the same line. It makes the cursor to be placed in the same line
Plz give the answers - Java Interview Questions
i cant remember which is the right one if(b==0) { c=c+i...Plz give the answers  1.Computing cos(x) using the cosine series...), is the number itself. Write a JAVA program to find all perfect numbers between 2
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
what is the correct format of charAt() function?
what is the correct format of charAt() function?  class prog...){ int i; // String s=search; for(i=0;i<=14;i++){ if(charAt(i)=='a'){ count++; } } System.out.println("count
Can u Look to the error plz - Java Beginners
Can u Look to the error plz  this is my code can u modify it plz and give me the result of it when u check it on eclipse or jcreator plz and i...;where is the answer sir.? just i want from you to look what is the error plz
Problem in my code - Development process
Problem in my code  Plz go thru this code. I want to check login and pwd with database. Backend MsAccess , Table name : Reg , Dsn Name: JJ While executing code am getting 404 error User Name Password
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
how to check username & password from database using jsp
how to check username & password from database using jsp  Hello, I.... in my oracle10G database already contain table name admin which has name, password. name is amit and password is ddave. so hw could i check whether the username
Help me quickly plz??
Help me quickly plz??  Can you help me to write code quickly this code is a java code take input as double and should use command line arguments and enhanced for statement then find the combine of the numbers plz help quickly
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
are my declared varibles right - Java Beginners
are my declared varibles right  here is what i have so far juswt wondering if my varibles are correct. public class Bug { public Bug(int... friend, Plz explain the problem in details and visit to : For read more
click on check box
click on check box  I create a check box in HTML and when i click on my check box relative information in page store in database
my assignment
...this is my assignment....plz...my assignment  as programmer, you have been assigned to develop a user interface for a fats food ordering system.the interface should have various
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
plz answer - Java Beginners
plz answer   Write a Binary Search program that searches an array..., f2 = 0, f3 = 1; for (int i = 0; i < intArray.length; i++) { f1 = f2; f2 = f3; f3 = f1 + f2; intArray[i]=f3; System.out.println(intArray[i
Gui plz help
Gui plz help   Create a Java application that would allow a person... ?Good Job? if the ratio of correct to incorrect answers exceeds 70% or you would do better next time if the ratio is smaller than 70%. this is what i got so
Syntax error in my UPDATE..please advise
Syntax error in my UPDATE..please advise  Hi experts, I tested my code and NetBean IDE gave me the following message:- You have an error...; stmt.executeUpdate(sql); Please advise how should I change my SQL to use Heidi MySQL
XML response correct in broser but incorrect in Java
XML response correct in broser but incorrect in Java  Firs of all I want to say that I was able to read XML response from URL. Thank you...;/body> </html> How can I get the correct result? Thank you
hi , i cant make this programmer , can any one help me to make it pls - Java Beginners
://www.roseindia.net/java/example/java/io/ Thanks  i want to make the whole program. i cant find delete records or update records  pls can...hi , i cant make this programmer , can any one help me to make it pls  
check box in jsp
check box in jsp  hey guys i am working on a web based project using jsp. In my project 1 am having 9 check boxes in 3 rows in the same form. I want to select 1 check box from each row and also i want to avoid many check box
correct the sql error and retrive data....plez
correct the sql error and retrive data....plez  i am getting a SQL Error while retriving data from access to jframe called "datatype mismatch...("")) { JOptionPane.showMessageDialog(null,"Please enter the Student ID to Search","Error",0

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.