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

Mr Siren Head replied to + !♛BS MATH!+♛'s discussion Result
54 minutes ago
Ghulam Murtaza GM liked saba zulfqar's profile
57 minutes ago
Ghulam Murtaza GM liked + !♛BS MATH!+♛'s profile
57 minutes ago
mohammad ahsan choudhry replied to + !♛BS MATH!+♛'s discussion Result
1 hour ago
sweet angel replied to + !♛BS MATH!+♛'s discussion Result
2 hours ago
+ !♛BS MATH!+♛ posted a discussion
2 hours ago
waseem akram left a comment for Huma Ahmad
11 hours ago
waseem akram left a comment for Huma Ahmad
11 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