TRENDING NEWS

POPULAR NEWS

What Is @test In Java I Found It On A Code .

Help with Student.java code?

public class Student
{
private String lastName;
private String firstName;
private int studentID;
private int units; //units taken
private int gradePoints ;

public Student( String lname, String fname, int id, int uts, int gpts) { }

public double gpa() { }

public void addGrade( int u, char grade) { } /* Adds u to the units variable and adds the grade points
corresponding to letter grade to gradePoints; prints an
error message if u <=0 or if grade is not an A, B, C, D, or F
and in that case does not make the changes*/

public String toString() { } /*Returns a string that prints the student data in following format:
Austen, Ann (1000 ) Units: 55 Grade Points: 56 GPA: 1.01 */


/*getters */
public String getLastName() { }
public String getFirstName() { }
public int getStudentID() { }
public int getUnits() { }

CAN SOME ONE EDIT MY JAVA CODE?

import java.util.*;

public class Grades
{
public static void main(String[] args)
{
Student student1 = new Student("Mary");
Student student2 = new Student("Mike");

student1.inputGrades();
student2.inputGrades();

System.out.println(student1);
System.out.println(student2);
}
}

class Student
{
int gradetest1, gradetest2;
String name;

public Student(String studentName)
{
name = studentName;
}

// inputGrades: prompt for and read in student's grades for test1 and test2.
// Use name in prompts, e.g., "Enter's Joe's score for test1".
public void inputGrades()
{
Scanner Sc = new Scanner(System.in);
do
{
System.out.println("Enter " + name + "'s First Test Grade:");
gradetest1 = Sc.nextInt();
if(gradetest1 < 0 || gradetest1 > 100)
{
System.out.println("Illegal value: enter grades again!");
continue;
}
else
{
break;
}
}while(true);

do
{
System.out.println("Enter " + name + "'s Second Test Grade:");
gradetest2 = Sc.nextInt();
if(gradetest2 < 0 || gradetest2 > 100)
{
System.out.println("Illegal value: enter grades again!");
continue;
}
else
{
break;
}
}while(true);
}

public int getAverage()
{
int average = gradetest1 + gradetest2;
return average/2;
}

public String getName()
{
return name;
}
public String toString()
{
return "Name: " + name + " Test1: " + gradetest1 + " Test2: " + gradetest2;
}

}

Where can I find a Java open source code project with a lot of test cases (more than 500)?

Over 500 tests: DaveVoorhis/Rel

How can I run my code in Java, test and debug it?

Google / Stack Overflow.

How can I write a test program to test if my stock class java code works?

i expect you want to implement something like this...

import java.text.*;

public class TestStock {
public static void main(String[] args) {
Stock test1 = new Stock();
Stock test2 = new Stock(34.5, 34.35);
print(test2);

unitTests();

System.exit(0);
}

private static void print(Stock stock) {
System.out.printf("Previous Closing Price: %,.2f%n", stock.getPreviousClosing());
System.out.printf("Current Price: %,.2f%n", stock.getCurrentPrice());
System.out.printf("Price Change: %,.2f%%%n", stock.getChangePercent());
}

/*
* Performs unit tests...
* Usage: java -ea TestStock.class
*/
private static void unitTests() {
Stock stock = new Stock(34.5, 34.35);
double expected = (34.35 - 34.5) / 34.5 * 100;
double actual = stock.getChangePercent();
assert (expected == actual) : System.out.printf("Expected <%f> but was <%f>%n", expected, actual);
System.out.printf("%f %f%n", expected, actual);

stock = null;
stock = new Stock(100, 150);
actual = stock.getChangePercent();
expected = 50;
assert (expected == actual) : System.out.printf("Expected <%f> but was <%f>%n", expected, actual);
System.out.printf("%f %f%n", expected, actual);
}
}

class Stock {
private double previous;
private double current;

public Stock() {
this(0, 0);
}

public Stock(double previous, double current) {
this.previous = previous;
this.current = current;
}

public double getPreviousClosing() {
return this.previous;
}

public double getCurrentPrice() {
return this.current;
}

public double getChangePercent() {
return (getCurrentPrice() - getPreviousClosing()) / getPreviousClosing() * 100;
}
}

Which course is better: Java or testing?

Hi friend Nice question..,Both java and testing are the developing field. first you fixed what domain you will interest. Both java and testing are good if want to go in for development you can learn java .if you learn selenium testing means java is the main thing to learn . we have well experience staff to trainee the student. we are no;1 training institution in Chennai.our trainers are more then 10+ years experience in that field. TIA academy offers various software training at affordable cost for career guidance reach us @996 252 8293Have any doubt. refer this website:Java Training in ChennaiThank you.., Best of luck

Is there a way to cheat on an online test that runs on java?

Download the Java app to your computer, and decompile it. After that, you should be able to search the source code for the answers.

If you aren't smart enough to be able to do this, you certainly aren't smart enough to have the option of cheating it.

What are some good ways to add unit tests to an existing Java codebase?

Unit testing an existing application is usually hard because the code was not designed to be tested. You will have to go through multiple sessions of refactoring to create an initial test suite. To make that process safe my recommendation would be to start by creating a set of high level end-to-end tests that you can run to validate core application functionalities. Also you need to make sure that any new code that gets added has appropriate unit tests.All this work implies fundamental changes in team culture. You may have to do some training sessions on how to write good unit tests, how to write testable code etc.

TRENDING NEWS