$29.99
CST 370 –
Homework 0
How to turn in?
• Write your answer to the question 1 and 2 and submit it on the iLearn. Note that we accept only a PDF file. Do not submit a different file format. Also, don’t forget to write your name and class ID at the top of your homework document.
• For the question 3, you should submit your C++ source file (hw0_1.cpp) on the iLearn.
• So, you have to submit two files (one PDF file and one C++ source file) on the iLearn.
• Note that the due date is 11:55(PM). This is the iLearn’s timestamp, not your submission time. Since there could be a long delay between your computer and iLearn, you should submit early.
1. In CST370, there will be three exams (= two midterms and one final exam). (True/False)
Indicate your answer (= either true or false) clearly.
2. _________ is the main programming language in CST370.
3. Write a C++ program called hw0_1.cpp that should read input data from an end user and display the correct result to the input data on the screen.
Input format: The input data will be composed of a few lines, and each line will have a command key and corresponding arguments. This is a list of command keys and their arguments.
Key Arguments Explanation Example
1 num1 num2 Sum of two integer numbers. 1 100 200
// Your program should read the two numbers (100 and 200). Then it should display 300 on the screen.
2 num1 num2 Calculate the difference of two integer numbers. 2 15 25
// Your program should display 10
// because the difference between
// 15 and 25.
// Note that the difference of two
// numbers always zero or positive
// number.
9 No argument Quit 9
// Your program should quit.
In this homework, you can assume that all input data is valid. For example, you can always assume that there will be two valid integer arguments for the command key 1.
Sample Run 1: Assume that the user typed the following three lines
1 1 2
1 -5 -9
9
This is the correct output of your program.
3
-14
Sample Run 2: Assume that the user typed the following six lines
1 15 200
2 -5 -9
2 10 10
1 10 10
2 5 -9
9
This is the correct output of your program.
215
4
0
20
14
HackerRank link: https://www.hackerrank.com/cst370-s20-hw0
=====================================================================
Programming Steps for Homework Submission
The following is the instructor’s recommendation for the homework programming,
Step 1: Read the homework description carefully
Before starting the programming, you should identify what the instructor wants. To get the requirement of the programming, read the homework description very carefully before starting the development.
Step 2: Develop the program at repl.it
After getting the requirement of the homework, go to repl.it (https://repl.it/) and start development there. While developing your program, you have to test it using the test cases provided in the homework description.
Step 3: Test at hackerrank.com
When you finish the development/testing at repl.it, go to the HackerRank website to test all test cases for the assignment. In the case of question 3 of the homework 0, this is the HackerRank link:
https://www.hackerrank.com/cst370-s20-hw0
In the website, you can run your program and check if your program passes all test cases.
Step 4: Submit your code on the iLearn
After testing your program on hackerrank.com, submit your source code on the iLearn.
In the source code, you have to include your code’s hackerrank link. Also, you should include the head comment such as “Title”, “Abstract”, “ID”, “Name”, and “Date”.
The following is a sample program in C++.
/*
* HackerRank link: https://www.hackerrank.com/contests/cst370-s20-hw0/challenges/370-hw0-1/submissions/code/1315408386
* Title: hw0_1.cpp
* Abstract: This program reads the user's input data and
* conducts sum and difference operations, depending
* on the command key.
* Author: Bob Otter
* ID: 8899
* Date: 01/23/2020
*/
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!\n";
return 0;
}