Preview

Wk5 Lab Joseph Laguerre

Satisfactory Essays
Open Document
Open Document
287 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Wk5 Lab Joseph Laguerre
COMP-274 Laboratory 5

Description of the Problem

Write a program that draws a series of eight concentric circles. The circles should be separated by 10 pixels. Use the drawArc method.

Sample Output

Program Template
1 // Lab 5 Circles.java
2 // This program draws concentric circles
3 import java.awt.*;
4 import java.awt.event.*;
5 import javax.swing.*;
6
7 public class Circles extends JFrame {
8
9 // constructor
10 public Circles()
11 {
12 super( "Circles" );
13 setSize( 300, 300 );
14 setVisible( true );
15 }
16
17 // draw eight circles separated by 10 pixels
18 public void paint( Graphics g )
19 {
20 super.paint( g );
21
22 // create 8 concentric circles

23
27 }
28
29 // execute application
30 public static void main( String args[] )
31 {
32 Circles application = new Circles();
33 application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
34 }
35
36 } // end class Circles

Follow-Up Question and Activity

Using method fillArc, modify the program so that when the variable topLeft is at 0, 20, 40 and so on, the circles would be filled with color cyan; otherwise, fill them with color gray

Source Code:

package week5.practice;

//Lab 5 Circles.java // This program draws concentric circles import java.awt.*; import java.awt.event.*;

import javax.swing.*;

public class Cirlces extends JFrame {

// constructor public Cirlces() { super( "Circles" ); setSize( 300, 300 ); setVisible( true ); }

// draw eight circles separated by 10 pixels public void paint( Graphics g ) { super.paint( g ); // create 8 concentric circles for ( int topLeft = 0; topLeft < 80; topLeft += 10 ) { int y = 160 - ( topLeft * 2 ); // setting colors for each circle if( topLeft== 0) g.setColor(Color.CYAN); if( topLeft== 10) g.setColor(Color.GRAY);

You May Also Find These Documents Helpful

  • Satisfactory Essays

    lab 4

    • 451 Words
    • 2 Pages

    Compare the portions that address Internet and e-mail access of at least three different companies.…

    • 451 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Equation 4 represents the intersection area between two circles whether the circumference of each circle passes through the centre of the other one and vice versa. Equation 5 is used to the area between two circles. With Equation 6, we formulate the difference between a quarter circle area and a half of A1 area.…

    • 88 Words
    • 1 Page
    Satisfactory Essays
  • Satisfactory Essays

    LAB 6

    • 5674 Words
    • 23 Pages

    CHM130 Lab 6 Exploring Density Name A. Data Tables Place your completed Data Tables here Part IIIa (3 points) Volume of water in graduated cylinder (mL)10 mlMass of rubber stopper (g)11.15Volume of water and rubber stopper (mL)16.5 Part IIIb (6 points) Volume of water in graduated cylinder (mL)20Mass of iron nail (g)3.66Volume of water and iron nail (mL)20.5 Part IV (20 points) Type of Aluminum FoilMass (g)Length (cm)Width (cm)Volume (cm3)Thickness (cm)Regular.63g15 cm 10.02 cm.21 cm3.0014 cm Heavy Duty.97g15 cm10.01 cm .36 cm3.0024 cm B. Follow Up Questions Show all work for questions involving calculations. Part I Use the concepts/vocabulary of density to explain why the liquids formed layers in Part I of the procedure. (8 pts) The liquids formed layers because they all had different densities. The liquids with light density were towards the top of the layers. What was the control used during the liquid portion of Part I of this experiment (8 pts) (Hint What did you do the same with each liquid to ensure a fair comparison) The control used during the portion of part I was the amount of liquid used. Rank the following in terms of relative density (9 pts) Isopropyl alcohol (rubbing alcohol) lowest relative density Liquid dishwashing detergent- intermediate relative density Dark corn syrup-high relative density Vegetable oil-second lowest relative density (intermediate) Glycerin-second highest relative density Rubber stopper- second highest relative density Cork stopper- low relative density (ended up with the alcohol Wood- low relative density (ended at the top with the rubber alchohol. Lead- highest relative density Part II (7 pts each) In Part II, what happened to the cans of soda when you placed them in water Use the concepts/vocabulary of volume and mass to explain the final positions of the cans in the sink full of water. The diet soda floated in the water while the regular soda sank. The regular soda had a higher relative…

    • 5674 Words
    • 23 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Lab 6

    • 690 Words
    • 3 Pages

    1. Run your model. Compare the queue statistics of the 3 processes with those obtained for Part C in the previous Lab. How have they changed and what conclusions can you draw? (Note the sums of all capacities for both cases are equivalent – 12 in each).…

    • 690 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    Lab 5

    • 2594 Words
    • 10 Pages

    In gymnosperms, pollination is the transfer of pollen (Fig. 2) from male cones (where pollen is produced) to female cones, which house eggs. In these plants, pollen is carried from male cones to female cones by wind - gymnosperms were the first plants to evolve that did not need free water to transfer sperm to egg, and were therefore able to thrive in terrestrial habitats. Pollen grains are also protected by tough coats. After fertilization, seeds are produced with developing embryos…

    • 2594 Words
    • 10 Pages
    Good Essays
  • Satisfactory Essays

    Lab 12

    • 441 Words
    • 3 Pages

    2. Use your procedure to find g on Planet X. Show your data, graphs, and calculations that support your conclusion.…

    • 441 Words
    • 3 Pages
    Satisfactory Essays
  • Powerful Essays

    Lab 12

    • 3059 Words
    • 13 Pages

    In this lab you will use the Wireshark packet analyzer to capture and display the control information and data stored in packets transmitted over a network. Wireshark collects network traffic data and creates files that display packet header information in a layered format like that used by the Internet model. These layers can be expanded to view details that may prove helpful in determining the source of problems that your network might be experiencing. Creating filters that hide unwanted data and facilitate data analysis will also be discussed in this lab.…

    • 3059 Words
    • 13 Pages
    Powerful Essays
  • Good Essays

    Lab 4

    • 575 Words
    • 3 Pages

    1.List four cell structures that were common to both plant and animal cells. (4 points)…

    • 575 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Lab 7

    • 928 Words
    • 3 Pages

    1. What are some common risks, threats, and vulnerabilities commonly found in the LAN-to-WAN Domain that must be mitigated through a layered security strategy?…

    • 928 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Lab 1

    • 414 Words
    • 2 Pages

    4. Why would you use a tool like DevManView while performing a computer forensic investigation?…

    • 414 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Random

    • 265 Words
    • 2 Pages

    To play connect four, you have a standing-up board with seven vertical rows of clear circles, and six horizontal rows of circles, making up a total of forty-two circles. You will also need two players, or a single person that will play as both. First, player one puts a red circle piece into one of the seven columns, and then player two puts a blue circle piece into one of the seven columns. The circle pieces will go to the lowest vacant spot on the vertical row it was selected on. You keep repeating these two steps until one player has four pieces horizontally, vertically, or diagonally. If all the circles are filled and none of them are winner patterns, than it is a tie between the players. My program will use graphics. The title screen will have three buttons, one is it play the game, the second will give instructions then loop back to the title, and the last will be “Quit”, which will exit the program. When you press “Play”, there will be a new screen that has the board, a score board that shows how many wins each player has. Once a player wins, or it is a tie, a mini screen will pop up to ask the player if he/she would like to play the game again, or return to the title screen Instead of making clear, circles, I will make a rectangle, than put the forty two circles on the rectangle. I will make the program a certain theme that I will come up with later.…

    • 265 Words
    • 2 Pages
    Good Essays
  • Good Essays

    Website report

    • 518 Words
    • 4 Pages

    Minor changes were made in order to change the syntax of the code to Java.…

    • 518 Words
    • 4 Pages
    Good Essays
  • Better Essays

    JAVA LESSON 6

    • 1293 Words
    • 6 Pages

    6: Design, Debugging, Interfaces 6.092: Introduction to Java Assignment 5: main() Programs start at a main() method, but many classes can have main() public class SimpleDraw { /* ... stuff ... */ public static void main(String args[]) { SimpleDraw content = new SimpleDraw(new DrawGraphics()); /* ... more stuff ... */ } } Assignment 5: main()…

    • 1293 Words
    • 6 Pages
    Better Essays
  • Good Essays

    Time Table

    • 518 Words
    • 3 Pages

    #include<GL\glut.h> void Display(){ glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_TRIANGLE_STRIP); glColor3f(255,255,0);//yellow glVertex2f(-0.5,0.9); glVertex2f(0.5,0.6); glVertex2f(-0.5,0.3); glColor3f(255,0,255);//pink glVertex2f(0.5,0.0); glColor3f(255,0,0);//green glVertex2f(-0.5,-0.3); glColor3f(0,255,255); glVertex2f(0.5,-0.6); glColor3f(0,255,0); glVertex2f(-0.5,-0.9); glEnd(); glFlush(); } void main(int argc, char** argv){ glutInit(&argc, argv); glutInitWindowPosition(0,0); glutInitWindowSize(400,600); glutCreateWindow("My Program!"); glutDisplayFunc(Display); glClearColor(1.0,1.0,1.0,0.0); glutMainLoop(); } 2. Draw a circle with the help of triangle fan. #include<GL\glut.h> #include<math.h> void Display(){ int section=100; float radius=1.0; float twoPi=2.0*3.14; glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_TRIANGLE_FAN); glVertex2f(0.0,0.0); for(int i=0; i<=section; i++){ glVertex2f(radius*cos(i*twoPi/section),radius*sin(i*twoPi/section)); if(i%8==0) glColor3f(0.0,0.0,0.0); if(i%8==1) glColor3f(0.0,0.0,1.0); if(i%8==2) glColor3f(0.0,1.0,0.0); if(i%8==3) glColor3f(0.0,1.0,1.0); if(i%8==4) glColor3f(1.0,0.0,0.0); if(i%8==5) glColor3f(1.0,0.0,1.0); if(i%8==6) glColor3f(1.0,1.0,0.0); if(i%8==7) glColor3f(1.0,1.0,1.0); } glEnd(); glFlush(); } void main(int argc, char** argv){ glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowPosition(0,0); glutInitWindowSize(600,600);…

    • 518 Words
    • 3 Pages
    Good Essays
  • Powerful Essays

    Smart Note Maker

    • 3815 Words
    • 16 Pages

    Since, JAVA Applet is suitable for both the drawings and strings, all these applications can be put together by developing a single JAVA program. The JAVA code that we will develop will also be installed on the pen so that the processor inside the pen will type and draw the desired shape or text on the display panel.…

    • 3815 Words
    • 16 Pages
    Powerful Essays