Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.

Views: 502

Replies to This Discussion

import java.util.Scanner;
public class Main
{
public static int isHappyNumber(int num)
{
int rem = 0, sum = 0;
//
while (num > 0)
{
rem = num % 10;
sum = sum + (rem * rem);
num = num / 10;
}
return sum;
}
public static void main(String[] args)
{
try {
Scanner scan = new Scanner(System.in);
String uid;
System.out.print("please Enter your vu Id ");uid = scan.nextline();
if (uid.length() <16 II uid.length() > 11)
{
System.out.prIntln("Provided Student Id is Wrong");
}
else
{
String id = uid.substring(2, 6);
System.out.println(id);
int count = Integer.parseInt(id.toString());
// Displays all happy numbers between 1 and N
System.out.println("List of happy numbers between 1 and " + id + " as");for (int i = 1; i<=count count; i++)
{
int result = i;
// Happy number reminder result 1 //unhappy number 4
while (result != 1 && result != 4)
{
result = isHappyNember(result);
}
if (result = 1)
{
System.out.print(I + " ");
}
}
}
catch(NumberFormatException ex){
System.out.print(ex);
}
}
}

kindly check the errors

Error Free Code :)

cs508.....rtf

RSS

Looking For Something? Search Below

Latest Activity

waseem akram left a comment for Huma Ahmad
5 hours ago
waseem akram left a comment for Huma Ahmad
5 hours ago
Hania Khalid Shariff is now friends with Mr Siren Head and Huma Ahmad
7 hours ago
saba zulfqar posted blog posts
10 hours ago
+ ¢αяєℓєѕѕ gιяℓ updated their profile
11 hours ago
saba zulfqar and Hania Khalid Shariff are now friends
13 hours ago
Mr Siren Head replied to Hania Khalid Shariff's discussion zero semester
19 hours ago
Profile Iconshahzad Hussain and Umar Farooq joined Virtual University of Pakistan
19 hours ago

VIP Member Badge & Others

How to Get This Badge at Your Profile DP

------------------------------------

Management: Admins ::: Moderators

Other Awards Badges List Moderators Group

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service