Course Home | Class Schedule | Moodle CMS | Git Submission | Perusall | Tutoring

Saint Louis University

Computer Science 1300/5001
Introduction to Object-Oriented Programming

Michael Goldwasser

Fall 2019

Computer Science Department

Homework Assignment 07a

Please make sure you adhere to the policies on academic integrity.


  1. (10 points)

    Write a program that allows the user to enter a nonnegative integerĀ \(k\) and returns the sum of the first \(k\) perfect squares, $$\sum_1^k{k^2}.$$ For example, if \(k=4\) the sum should be \(1^2 + 2^2 + 3^2 + 4^2 = 1 + 4 + 9 + 16 = 30\). A sample execution might appear as

    Enter k: 4
    30
  2. (10 points)

    Ask the user for a word and then output the following pattern.

    Enter word: example
    e
    ex
    exa
    exam
    examp
    exampl
    example
    

Michael Goldwasser
CSCI 1300/5001, Fall 2019
Last modified: Sunday, 22 December 2019
Course Home | Class Schedule | Moodle CMS | Git Submission | Perusall | Tutoring