Assignment #1 (1).pdf - COMP 1602 \u2013 Computing Programming II Assignment#1 Date Due Sunday February 2 2019 11:59 pm Description A set of students were

Assignment #1 (1).pdf - COMP 1602 – Computing Programming...

This preview shows page 1 - 2 out of 2 pages.

COMP 1602 – Computing Programming II Assignment #1 Date Due: Sunday February 2, 2019 @ 11:59 pm 1 Description A set of students were polled to find out their favourite number between 1 and 100 (inclusive). The numbers are stored in a file, numbers.txt . The amount of students is not known beforehand but -1 terminates the data. Zero is stored in the file if a student does not wish to reveal his/her favourite number. a) Write a program which opens the file and reads all the numbers specified by the students. b) For each distinct number specified by the students, you must do the following if the number is valid (i.e., between 1 and 100): i) Determine if the number is perfect – a perfect number is a positive integer that is equal to the sum of its proper divisors (i.e., does not include the integer itself), e.g., 6. ii) Determine if the number is prime – a prime number is a number that is divisible only by itself and 1, e.g., 7. iii) Determine if the number is a perfect square – a number that can be expressed as the product of two equal integers, e.g., 25 which is the product of 5 and 5.
Image of page 1
Image of page 2

You've reached the end of your free preview.

Want to read both pages?

  • Spring '17
  • Natural number, Prime number, Favourite Number

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes