Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, can you solve it with processing java with explanation? Thanks. Q1: SINGLE-DIGIT NUMBERS [6 MARKS] In this question, you'll set up your program with

Hello, can you solve it with processing java with explanation? Thanks.

image text in transcribed

Q1: SINGLE-DIGIT NUMBERS [6 MARKS] In this question, you'll set up your program with the general structure and canvas layout that you need, and start by converting any number from 0 to 9 ( 1 digit) into Cistercian numerals. The program should initially prompt the user to enter a number that will be converted. For this question, you can assume that only numbers 0 to 9 will be entered. To use the input dialog, you must add import javax. swing. JoptionPane; as the very first line in your program. Then, when you want to obtain user input, a line of code such as userText - JoptionPane.showInputdialog ("Please enter text:"); will display the dialog. The String parameter contains the text displayed for the user, and a String is returned. The returned String should be stored for converting the number. It is very important that you do not convert the String into an int or other number format, this is particularly important when you get to Q3. Once the program accepts the input, it must convert the number into a Cistercian numeral. To start, you'll draw an empty, vertical stave taking up most of the canvas (looks like 0 , below). Then, depending on the number that was entered, you must draw one or two strokes off the stave that represents the number, as follows: Your code should follow these requirements: - Avoid duplicating code. Note that there are only five types of strokes, and some glyphs use a combination of strokes: use this to your advantage to shorten your code. If you are careful every one of your lines of code will be doing something different, you will not have any duplicate code. - Again, avoid duplicating code. You can assume that the strokes all have their endpoints at the corners of an invisible square: two points are on the stave, two are off the stave, and all points are equidistant. If you store these four points somewhere, you should be able to use them to draw any stroke you want with minimal effort. - Keep in mind that you are storing the input number as a String, so you should be comparing it to chars of digits (e.g., '1', not 1 ). - Hint: You do not need to use functions for each individual digit/stroke! If you do, you may run into problems with Q2 and Q3, unless you read Unit 14, which is about functions (Week 9). In addition to drawing the glyph, your canvas should display the original number, and contain a button that when pressed, will ask the user for new input, and erase the existing number and glyph(s) (this will also be useful to you when testing different numbers). Make changes to default parameters to make the output more appealing (e.g., background colour, text colour, glyph colour, stroke widths...)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Temporal Databases Research And Practice Lncs 1399

Authors: Opher Etzion ,Sushil Jajodia ,Suryanarayana Sripada

1st Edition

3540645195, 978-3540645191

More Books

Students also viewed these Databases questions