NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

/**
* This program plots survey results on a bar graph using Turtle graphics methods
*
* @author Sijia Liang
* @version 7/26/2016
*
*/
import java.awt.*;
import turtlegraphics.*;
class Survey
{
public void prepareTurtleToDraw(Turtle myrtle, Color color, int x1, int y1, int width, int x2, int y2)
{
myrtle.hide();
myrtle.penUp();
myrtle.setPenColor(color);
myrtle.setPenWidth(width);
myrtle.moveTo(x1, y1);
myrtle.penDown();
myrtle.moveTo(x2, y2);
}
//end of preparing to draw with turtle
public int convertStringToInt(String stringOfDigits)
{
int number = 0; //declare and initialize the number variable
int total = 0; //declare and initialize the total variable
String subData = ""; //declare and initialize the subData variable

for(int n = 0; n < stringOfDigits.length() ; n+=1) //traverse the length of the loop by increments of 2
{
subData = stringOfDigits.substring(n, n+1); //pick out the substrings of 2 digit numbers
number = Integer.parseInt(subData); //parse a string to an integer
total+=number; //accumulate the total
}//end of loop

return total; //return the total calculated

}//end of method
}
public class SurveyTester
{
public static void main(String[] args)
{
Picture pictureObj = new Picture("C:\Users\School-pc\Desktop\CP1 Course Files\Module 7\Mod07 Documents\blank.jpg");
World worldObj = new World();
worldObj.setPicture(pictureObj);
Turtle myrtleTheTurtle = new Turtle(2000, 2000, worldObj);
Survey demo = new Survey();
//end of setting up background

String likeDog = "5";
String likeCat = "4";
String likeBird = "1";
//end of setting string values

int likeDogValue = Integer.parseInt(likeDog);
int likeCatValue = Integer.parseInt(likeCat);
int likeBirdValue = Integer.parseInt(likeBird);
//end of changing string to integer

demo.prepareTurtleToDraw(myrtleTheTurtle, Color.BLACK, 200, 375, 10, 200, (35 * likeDogValue));
demo.prepareTurtleToDraw(myrtleTheTurtle, Color.BLACK, 325, 375, 10, 325, (55 * likeCatValue));
demo.prepareTurtleToDraw(myrtleTheTurtle, Color.BLACK, 450, 375, 10, 450, (340 * likeBirdValue));
//end of drawing survey results

// TODO Auto-generated method stub

}

}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.