We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi all, I need help on how to go about my programming assignment about designing a number system calculator. It's a very important part of my CA. Any help would be appreciated. I'm new to programming... Below is the detail of the assignment. Thanks.
Design your own Number system calculator. It must read in a Decimal value and convert the value to a Hexadecimal, Octal and Binary. The application must work and show the objectives listed below
Objectives:
1. Design a GUI (Graphical User Interface)
2. Declare a local and global variable and initialize them.
3. Use a for loop.
4. Implement if else statement.
5. Declare an Array and access each element of the Array.
6. Write a function, call and return a value from the function.
7. Preform a calculation.
8. Fully comment all code.
9. Use the mouse functions
10. Use the keyboard functions.
Session 1: Design GUI on paper. Write code to implement GUI (Graphical User Interface). Session 2: Take data in from the GUI using the Keyboard and/or the Mouse. Session 3: Calculate from DEC ‐> BIN DEC ‐> HEX DEC ‐> OCT (Create a function) Session 4: Finish up final code. Comment all code.
Answers
So, did you do anything yet? For example, did you "Design GUI on paper"? That seems like a crucial first step, and it isn't a part of your homework that people can just do for you.
Thanks for your response. Yes I did, and this is how far I have gone...
void setup() {//returns no value size(300,300);//sets the window size to width 500 and height 500 //rect(0,50,35,35);//draws a square of width 50 and height 50 rect(0,170,75,35); } void draw() { rect(0,5,200,40);
for (int i = 50; i < 140; i = i+40) { fill(250,250,230); rect(0,i,35,35); //fill(0); //text((i/50)/50, 10, i+10); } fill(0); text("7", 10, 75); text("4", 10, 115); text("1", 10, 150); text("0", 30, 190);
for (int x = 50; x < 140; x = x+40) { fill(250,250,230); rect(40,x,35,35); }
for (int y = 50; y < 140; y = y+40) { rect(80,y,35,35); }
}
Format your code - select code, ctrl + o to indent, leave a line above and below.
Thanks a lot Jeremydouglass and Lord_of_the_Galaxy. This is how far I have gone. I don't know where to go from here. Your help will be appreciated.
Hey, try using a button class. Here is a demo.
For reference, https://processing.org/tutorials/objects/
Kf
Better still, replace line 58 of @kfrajer's code wit this -
rect(x, y, w, h, 0.35*h);
.Thanks to all who showed concern