1 / 2100%
public class Geek
{
private String name;
private int NumberOfQuestions;
public Geek(String name, int numQuestions)
{
this.name= name;
NumberOfQuestions=numQuestions;
}
public String getName()
{
return (name);
}
public int getNumberOfQuestions()
{
return (NumberOfQuestions);
}
boolean isEven (int num1, int num2)
{
NumberOfQuestions++;
boolean even;
if ((num1+num2)%2==0)
even= true;
else
even=false;
return even;
}
public int sum(int num1, int num2)
{
NumberOfQuestions++;
if (num1 == num2)
{
return num2;
}
int total = 0;
if(num1 <= num2)
{
while(num1<=num2)
//***********************************************************
Assignment 6
// Name: Ana Aguilar
// Title:
// Author: Ana Aguilar
// Description: We wrote a class definition that asks a Geek different
questions. We implemented several methods and only two
// instance variables in this class.We also filled out the file with the main
method that tests the methods defined in the Geek class.
// Time spent: 3 hours
// Date: 10/30/14
//**********************************************************
{
total += num1;
num1++;
}
return total;
}
if(num2 <= num1)
{
while(num2<=num1)
{
total += num2;
num2++;
}
return total;
}
return total;
}
public boolean leapYear (int year)
{
NumberOfQuestions++;
return (year%400==0||(year%100!=0 && year%4 == 0));
}
}
Powered by TCPDF (www.tcpdf.org)
Students also viewed