CSC 120 Study Guide - Final Guide: Newline, String Literal, Computational Problem
champagnegnat971 and 18 others unlocked
26
CSC 120 Full Course Notes
Verified Note
26 documents
Document Summary
Suppose we are to write a container class dowhat for the purpose of storing two pieces of information in two instance variables, a string by the name of word and an int by the name of quantity. Answer the following questions: (3 points) write a constructor public dowhat(string word, int quantity) that stores the two parameter values as the initial values of the two instance variables, respectively. Answer public dowhat(string word, int quantity) { this. word = word; this. quantity = quantity: (3 points) write a public method for retrieving the value of word as a string. Fill the holes in the description below (1 point each) Consider the method method123 below. public static double method123(double input) { if (input < 11. 0) { return input + 1; if (input < 12. 0) { return input + 2; return input - 5; Answer the return value of method123 for each of the value for input (2 points each): 10. 0, 11. 0, 13. 0.