0% found this document useful (0 votes)
46 views

Uploading Instructions:: Tio - Run/#java-Jdk

This document provides instructions for Assignment 03 in the CS508 - Modern Programming Languages course. Students are asked to write a Java program that prints all happy numbers between 1 and the first 4 digits of the student's ID. The program should take the student ID as input, print it at the top, extract the first 4 digits after the degree prefix, run a loop that number of times to check for happy numbers, and print any happy numbers found. Sample output and compilation instructions are provided. The assignment must be submitted as a zip file containing the Java code and a gif showing execution, using the student's ID as the file and folder names. Late or plagiarized assignments will not receive credit.

Uploaded by

Xyeme
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Uploading Instructions:: Tio - Run/#java-Jdk

This document provides instructions for Assignment 03 in the CS508 - Modern Programming Languages course. Students are asked to write a Java program that prints all happy numbers between 1 and the first 4 digits of the student's ID. The program should take the student ID as input, print it at the top, extract the first 4 digits after the degree prefix, run a loop that number of times to check for happy numbers, and print any happy numbers found. Sample output and compilation instructions are provided. The assignment must be submitted as a zip file containing the Java code and a gif showing execution, using the student's ID as the file and folder names. Late or plagiarized assignments will not receive credit.

Uploaded by

Xyeme
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment No.

03
Total Marks: 20
Semester: Spring 2021 Due Date: 26 Jul 2021
CS508 – Modern Programming Languages

Please read the following instructions carefully before solving & submitting assignment:

Uploading Instructions:
o You can use simple Notepad or any other text editor (like Sublime Text, Atom, VS Code etc.) for coding.
o For compilation purpose, any online compiler can be consulted, like tio.run/#java-jdk
o Following files must be submitted in a single Zip or RAR file.
 Java code file (file name should be your own VU Student Id, e.g., bs123456789.java)
 A .gif file (e.g., bs123456789.gif) which should show only "execution" of your code (For
Recording .gif, a software named ScreenToGif is uploaded at VU-LMS; bit.ly/3edPzFX, or you can
use any other gif recording tool as well)
 First record must be with your own VU Student Id in .gif file.
o After finalizing, put both files in a single folder, rename it to your own VU Student Id, compress it with Zip
or RAR format and submit at VU-LMS within due date.
o No assignment will be accepted through email.

Rules for Marking:


It should be cleared that your assignment will not get any credit if:
o The assignment is submitted after due date.
o The assignment is not submitted in .zip or .rar format.
o The submitted assignment does not open or file is corrupt.
o The assignment is fully or partially copied from other student or ditto copy from handouts or Internet;
strict disciplinary action will be taken in this case.
o You do not submit any of the above-mentioned files or use some other VU Student Id; Zero Marks will be
awarded, and no excuse will be accepted in any case.

Note: Do not put any query on MDB regarding this assignment, if you have any query then email at
[email protected]

Lectures Covered: This assignment covers Lectures 23 to 30.

GOOD LUCK

1
Assignment No. 03
Total Marks: 20
Semester: Spring 2021 Due Date: 26 Jul 2021
CS508 – Modern Programming Languages

Problem Statement:
A number (positive integer) is said to be a happy number if it yields 1 when it is replaced by the sum of the
square of its digits repeatedly. Or in simple words, the number for which the process of summing up of the
squares of its digits ends in 1 is a happy number. For example, 32 is a happy number as the process ends in
1, as shown below;

32 => 32 + 22 = 9 + 4 = 13
12 + 32 = 1 + 9 = 10
12 + 0 2 = 1 + 0 = 1

On the other hand, if number that does not end in 1 is called an unhappy or sad number. For example, 42 is
an unhappy number as the process does not end in 1, as shown below;

42 => 42 + 22 = 16 + 4 = 20
22 + 0 2 = 4 + 0 = 4

You are required to write a Java program which will print all happy numbers between 1 and first 4 digits
(after degree prefix) of your student id. If your student id is BS123456789 then print all happy numbers
between 1 and 1234.

 You need to take student Id as input from user.


 Print student Id on top of the console screen.
 Take first 4 digits from student Id after degree prefix (i.e., BC/BS).
 Then run a loop which should execute according to value of first 4 digits (e.g., 1234
times).
 During each iteration, check whether it is a happy number or not.
 If it is a happy number, then just print the number on console, otherwise skip it.
 Repeat the same for all numbers in the loop.

2
Assignment No. 03
Total Marks: 20
Semester: Spring 2021 Due Date: 26 Jul 2021
CS508 – Modern Programming Languages

Note:
It is required to make sure that the program should not accept such student id which length is less
than 6 or greater than 12 characters. Furthermore, NumberFormatException must be implemented when
fetching first four digits (after degree prefix) from student id.

Sample Output:
See the gif file attached with this assignment file.

Compiler:
For compilation purpose, you can consult any online Java compiler, like tio.run/#java-jdk

Note:
DO REMEMBER that you must use your own VU Student ID as an input in this program.

Good Luck

You might also like