Category | Assignment | Subject | Programming |
---|---|---|---|
University | Ulster University | Module Title | COM413: Mobile Application Development |
Create a program to calculate and print the sum of all even numbers between 1 and a given positive integer. For example, ask the user to input a positive number, we’ll say 10. We can then add the even numbers in two ways, start at 2 and add 2 each time until the positive number is reached or modulus each number in the range by 2 (%2) if the result is 0, the number is even. Create two
methods, and test the code in order to determine the fastest method.
So, from 1 to 10, the even numbers are: 2, 4, 6, 8 and 10 and the sum of all these numbers is 30. You should use System.nanoTime().
Create a program to determine if a given number is prime or not. A prime number is only divisible by 1 and itself.
To check if a number is prime, you only need to test divisibility with integers up to its square root. If no divisors are found within this range, the number is prime. This approach optimizes the prime number checking process by reducing unnecessary calculations and iterations.
If a number is not prime, it can be represented as the product of two factors, a and b, where 1 < a <=
b. One of these factors, a or b, will be less than or equal to the square root of the number we are checking. If both factors were greater than the square root of this number, their product would begreater than num.
E.g. 811 is a prime number, the Square root of 811 is 28.48, therefore, we don’t need to check if 811 is divisible by numbers greater than 28 as 29x29 = 841 which is too big
Create a program to find the maximum and minimum values in an array of integers. Ask the user how many numbers they want to add to an array, if they say 5. Ask them for each number. When the array is complete, the program will then search through the array for the smallest number and then the largest number. Use two separate methods to calculate these.
Student Name. B-number.
Create a program to convert temperatures between Celsius and Fahrenheit. The formula for the conversion is: (0°C × 9/5) + 32 = 32°F
You should ask the user to select from a conversion from degrees Celsius to Fahrenheit or Fahrenheit to degrees Celsius.
Create a program to check whether a given string is a palindrome (reads the same forwards and backwards). An example of a palindrome is the word Racecar. Ask the user to input a word, and pass the string as a parameter. Don’t forget to use the string.toLowerCase() method.
You can then check the characters match from left to right.
Create a program which can calculate the volume of a sphere or cylinder using the formulas below:
You should ask the user to input either sphere or cylinder in some way and then use a method to calculate and return the result. Print the result to 2 d.p.
Use the math function Math.pow(double n, double p) to calculate a number n to power p. Likewise use the Math.PI constant to obtain the value of Pi.
Create a program which will print various patterns using nested loops. There should be 3 options:
Square, right-handed triangle and pyramid.
Create a program which will convert a decimal number to Roman numerals. Roman numeral converters can convert numbers from 1 to 3,999 into Roman numerals.
Roman numerals are a number system developed in ancient Rome where letters represent numbers.
The modern use of Roman numerals involves the letters I, V, X, L, C, D, and M.
There are a number of ways to do this, first prompt your user to enter a number between 1 and 3,999. Next you can call a method and pass the number as a parameter. Using a String array to record your new array made up of Roman Numerals, you can take the original number and divide it by thousands, hundreds, tens and ones.
On paper this is done as such:
Let’s use the number 3450 as an example.
If we divide 3000 by 1000 we get 3 = this is 3 Ms so the equivalent is MMM We divide 400 by 100 we get 4 = this is not CCCC but in Roman numerals it would be C(100) D (500) or CD.
We have a remainder of 50 which is equivalent to L so the String would read MMMCDL.
An easy way to do this is to have 4 arrays, one each for thousands, hundreds, tens and ones and use the corresponding array position to create your string: String[] thousands = {"", "M", "MM", "MMM"};
Verify your output here: https://www.calculatorsoup.com/calculators/conversions/roman-numeralconverter.php
Create a program which will convert a phrase into simple Pig Latin. Pig Latin is a language game or argot in which words in English are altered, usually by adding a fabricated suffix or by moving the onset or initial consonant or consonant cluster of a word to the end of the word and adding a vocalic syllable to create such a suffix. https://www.wikihow.com/Speak-Pig-Latin
This has 2 principles:
1. If the word starts with a vowel (AEIOU) you add “-ay” to the end of the word. Elephant would become elephant-ay.
2. If it starts with a consonant, you start the word from the first vowel in a string and add the consonant cluster onto the end and again add the suffix ay. So, Hello would become ellohay.
This becomes more complicated with more words. So, start with one word, and check for vowels.
Next, when dealing with a consonant, remove the first letter only and add it to the end with ay.
Note: It is possible to use the indexof function to find the next vowel and create a substring by removing the characters that precede the vowel but this gets too complicated.
Verify your results here: https://joekarlsson.github.io/Pig-Latin/
Now we want to build a Hex to decimal converter. Hexadecimal is a numbering system with base 16.
It can be used to represent large numbers with few digits. In this system there are 16 symbols or possible digit values from 0 to 9, followed by six alphabetic characters -- A, B, C, D, E and F see below.
A – 10 D - 13
B – 11 E - 14
C – 12 F - 15
We want to create a program which will read an array of Hex values and convert this to its corresponding decimal value.
How we do this is we use a table as such:
3B in base 16 is equal to each digit multiplied with its corresponding 16n:
3B16 = 3×161
+11×160 = 48+11 = 5910
https://www.rapidtables.com/convert/number/hex-to-decimal.html?x=FF
We use the base 16 and we multiply it by the number in the array, depending on the position of the array we can use 16i or 16[i] to represent the Most Significant Bit (MSB) down to the Least Significant Bit (LSB). What we do is read an array as such:
We can then calculate: FF16 = 15×161 +15×160 = 240 + 15 = 255.
If you are looking for solutions to your assignment of COM413: Mobile Application Development, then our Programming Assignment Help Services is just that. Thus, you can be sure that Ulster University students get perfect university assignment help; there you will get expert guidance, especially on the key areas of mobile app development such as coding, UI/UX design, and app functionality. With our assignment writing services in UK, you also get free samples written by PhD experts, and are absolutely original content. So make your assignment easier, get in touch now!
To get a solution for this course, click here: COM413 Mobile Application Development Example
Let's Book Your Work with Our Expert and Get High-Quality Content