Question: This homework must contain Java code AND C code. ava Requirements: Must have a user-interface function which requests the user to enter an integer. If
This homework must contain Java code AND C code.
ava Requirements:
Must have a user-interface function which requests the user to enter an integer.
If the given number is less than or equal to 0, the program must display an error message and prompt the user to re-enter a value.
Contains a print function which uses a for loop to generate a list of factors starting from 1 to the given number itself with indeces.
------------------------------------------------------------------------
Homework 1:
Contains a user-interface function which requests the user to enter a integer, and returns the given integer.
If the given value is a character or string, the program must display an error message and prompt the user to enter an integer. You only need to test for the input of characters and integers. You do not have to worry about floats being entered.
If the given number is less than or equal to 0, the program must display an error message and prompt the user to enter a positive integer.
Contains a print function which uses a for loop to generate a list of factors starting from 1 to the given number itself with indeces. (see the sample below)
Contains a function called isDivisible with the following prototype:
int isDivisible(int,int);
The table must be formatted. (see the sample below)
Columns must be right-aligned.
| No. | Factor |
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | 4 |
| 5 | 6 |
| 6 | 8 |
| 7 | 9 |
| 8 | 12 |
| 9 | 18 |
| 10 | 24 |
| 11 | 36 |
| 12 | 72
|
C Requirements:
Contains a function called isDivisible with the prototype shown below:
int isDivisible(int,int);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
