Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

Unionville Hs AP COMP SCI 11 Chapter 4 Programming Projects

Rating
-
Sold
-
Pages
25
Grade
A+
Uploaded on
04-07-2021
Written in
2020/2021

Counter public class project1 { int count; public project1 (){ count = 0; } public void click() { count++; }p ublic int getpublic1() { return count; }p ublic int reset() { count = 0; return count; } } C ountertest public class project1part2 { public static void main(String[] args) { project1 classcount1 = new project1(); project1 classcount2 = new project1(); (); (); (); int sum = blic1() + blic1();Sln("The count after click is " + sum); (); (); sum = blic1() + blic1(); Sln("The count after the reset is " + sum); } } b ulb public class Bulb { String light; public Bulb() { light = "off"; } p ublic String TurnOn() {li ght = new String("on"); return light; } p ublic String TurnOff() { light = new String("off"); return light; } }Lights public class BulbPart2 { public static void main(String [] args) { Bulb bulb1 = new Bulb(); Bulb bulb2 = new Bulb(); String bulb3 = bulb1.TurnOff(); String bulb4 = bulb2.TurnOff(); Sln("Bulb one is "+bulb3); Sln("Bulb two is "+bulb4); bulb3 = bulb1.TurnOn(); bulb4 = bulb2.TurnOff(); Sln("Bulb one is "+bulb3); Sln("Bulb two is "+bulb4); bulb4 = bulb2.TurnOn(); Sln("Bulb one is "+bulb3); Sln("Bulb two is "+bulb4); bulb1.TurnOff(); Sln(String()); } } S phere public class Sphere { double diameter; double volume; double surfacearea;public Sphere(int diameter) { ter = diameter; } p ublic double getDiameter() { return diameter; } p ublic void setDiameter(double diameter) { ter = diameter; } p ublic double toVolume() { double volume = (4/3)*Math.PI*M(diameter/2, 2); return volume; } p ublic double toSurfacearea() { double surfacearea = 4 * Math.PI * M(diameter/2, 2); return surfacearea; }p ublic String toString() { return ("The surface area is " + toSurfacearea() + " and the volume is " + toVolume()); } }

Show more Read less
Institution
Course

Content preview

Counter



public class project1 {

int count;

public project1 (){
count = 0;
}
public void click() {

count++;
}
public int getpublic1()
{
return count;
}
public int reset()
{
count = 0;
return count;

}

}




Countertest



public class project1part2 {

public static void main(String[] args) {

project1 classcount1 = new project1();
project1 classcount2 = new project1();

classcount1.click();
classcount1.click();
classcount2.click();
int sum = classcount1.getpublic1() + classcount2.getpublic1();

, System.out.println("The count after click is " + sum);
classcount1.reset();
classcount2.reset();
sum = classcount1.getpublic1() + classcount2.getpublic1();
System.out.println("The count after the reset is " + sum);




}

}




bulb



public class Bulb {

String light;

public Bulb() {
light = "off";
}



public String TurnOn()
{
light = new String("on");
return light;
}

public String TurnOff()
{
light = new String("off");
return light;
}

}

, Lights



public class BulbPart2 {



public static void main(String [] args) {

Bulb bulb1 = new Bulb();
Bulb bulb2 = new Bulb();



String bulb3 = bulb1.TurnOff();
String bulb4 = bulb2.TurnOff();
System.out.println("Bulb one is "+bulb3);
System.out.println("Bulb two is "+bulb4);

bulb3 = bulb1.TurnOn();
bulb4 = bulb2.TurnOff();
System.out.println("Bulb one is "+bulb3);
System.out.println("Bulb two is "+bulb4);

bulb4 = bulb2.TurnOn();
System.out.println("Bulb one is "+bulb3);
System.out.println("Bulb two is "+bulb4);

bulb1.TurnOff();
System.out.println(bulb1.toString());

}
}




Sphere



public class Sphere {

double diameter;
double volume;
double surfacearea;

Written for

Institution
Secondary school
Course
School year
2

Document information

Uploaded on
July 4, 2021
Number of pages
25
Written in
2020/2021
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$12.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Examhack Stanford University
Follow You need to be logged in order to follow users or courses
Sold
296
Member since
4 year
Number of followers
238
Documents
999
Last sold
1 week ago
EASY A GRADE!!

Here, you will find simple, articulate well-researched education material for you. .... ALL WORK HAS PASSED WITHOUT NEEDING REVISIONS AND BY THE RUBRIC.

3.8

61 reviews

5
31
4
11
3
5
2
4
1
10

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions