So I have just started studying processing at university, but unfortunately missed the firth few lectures, so with the text books at hand, I am attempting to learn this my self, could someone let me know if im right or wrong with this? You would be saving my life. kinda.. thanks 😀
This is the question:
Write a program which declares and initialises the following variables
with their values. Add comments to your program to separate the
different subsections. i. noOfstudents =50 ii. examMark = -50
iii. priceOfShoes = 59.99 iv. income = 10,750.99 v.
greetingMessage=’hello there’ vi. alphabet = ‘A’vii lossOfIncome = -20.30
viii sum=0.0000000000076
and this is the code I have typed up for the question;
void setup() {
int noOfStudents;
noOfStudents = 50; //Number of Students
float examMark;
examMark = -50; // Exam Mark
float shoePrice;
shoePrice = 59.99; // The price of the shoes
double income;
income = 10750.99; // The income
print ("hello world"); //displays hello world
char message;
message = 'A'; //displays the character A
float lossOfIncome = -20.30;
double lossOfIncome2 = 0.0000000000076; //The loss of income
}
you could declare and init your variables on one line, ie
int noOfStudents = 50;. Also, you are using theprint()method. It is more likely you would want to use theStringvariable type.You might also want to take a look at Ch. 4 of Daniel Shiffman’s, Learning Processing book, or at least the examples for ch. 4 online.
http://www.learningprocessing.com/examples/