Computer Science  >  STUDY GUIDE  >  Unionville Hs AP COMP SCI 11 Chapter 4 Programming Projects (All)

Unionville Hs AP COMP SCI 11 Chapter 4 Programming Projects

Document Content and Description Below

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; r ... eturn count; } } C ountertest 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); } } 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(); 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()); } } S phere public class Sphere { double diameter; double volume; double surfacearea;public Sphere(int diameter) { this.diameter = diameter; } p ublic double getDiameter() { return diameter; } p ublic void setDiameter(double diameter) { this.diameter = diameter; } p ublic double toVolume() { double volume = (4/3)*Math.PI*Math.pow(diameter/2, 2); return volume; } p ublic double toSurfacearea() { double surfacearea = 4 * Math.PI * Math.pow(diameter/2, 2); return surfacearea; }p ublic String toString() { return ("The surface area is " + toSurfacearea() + " and the volume is " + toVolume()); } } [Show More]

Last updated: 3 years ago

Preview 1 out of 25 pages

Buy Now

Instant download

We Accept:

Payment methods accepted on Scholarfriends (We Accept)
Preview image of Unionville Hs AP COMP SCI 11 Chapter 4 Programming Projects document

Buy this document to get the full access instantly

Instant Download Access after purchase

Buy Now

Instant download

We Accept:

Payment methods accepted on Scholarfriends (We Accept)

Reviews( 0 )

$11.00

Buy Now

We Accept:

Payment methods accepted on Scholarfriends (We Accept)

Instant download

Can't find what you want? Try our AI powered Search

48
0

Document information


Connected school, study & course


About the document


Uploaded On

Jul 04, 2021

Number of pages

25

Written in

All

Seller


Profile illustration for d.occ
d.occ

Member since 4 years

232 Documents Sold

Reviews Received
30
8
4
1
7
Additional information

This document has been written for:

Uploaded

Jul 04, 2021

Downloads

 0

Views

 48

Document Keyword Tags

Recommended For You

Get more on STUDY GUIDE »

$11.00
What is Scholarfriends

Scholarfriends.com Online Platform by Browsegrades Inc. 651N South Broad St, Middletown DE. United States.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Scholarfriends · High quality services·