首页 > 其他分享 >COMP 218 Fundamentals of Object-Oriented Programming

COMP 218 Fundamentals of Object-Oriented Programming

时间:2024-09-28 08:50:15浏览次数:1  
标签:Fundamentals COMP Object Question number program output pts your

© May not be copied or duplicatedwithout the permission of the owner.

COMP 218 Fundamentals of Object-OrientedProgrammingAssignment 1

Please note: you are NOT allowed to post the assignment/solution anywhere on the Internet. Intellectual Property rights are reserved. If any similar cases are found via your account or IP, your submission will NOT be considered and will be reported immediately.

General Guidelines when Writing Programs: - Include the following comments at the top of your source codes

// -----------------------------------------------------

// Assignment (include number)

// Question: (include number)

// File name: (include source code file name)

// Written by: (include your name and student id)

// -----------------------------------------------------

- In a comment, give a general explanation of what your program does. As theprograming questions get more complex, the explanations will get lengthier.

- Include comments in your program describing the main steps in your program.

- Print a welcome message which includes your name.

- Display clear prompts for users when you are expecting the user to enter datafrom the keyboard.

- All output should be printed out with clear messages and in an easy to readformat.

- End your program with a closing message so that the user knows that theprogram has terminated.©2

© May not be copied or duplicatedwithout the permission of the owner.

Question #1: Display a message (3 pts)

Write a complete C++ program that displays the following output exactly as in thesample output. You are to use a single cout statement to output the message. There isno need to declare any variables for this question.Figure 1 – Sample output for Question 13

© May not be copied or duplicatedwithout the permission of the owner.

Question #2: Number Generator Program (6 pts)

In C++, we can use rand() function (More details) to generate random numbers. In thenumber calculation following the requirements:

  1. Display a welcome message.
  2. Display the randomly generated even/odd number.

Figure 2 – Sample output #1 for Question 代 写COMP 218 Fundamentals of Object-Oriented Programming  2For example, if the number is 1234, change it to 4321.For example, 1221 is a palindrome as it is the same if reversed.For example, the largest digit is 9 and smallest is 1, in 3179.Your program must display the same information and formatted the same.

  1. Reverse the number.
  2. Check if the number is a palindrome.
  3. Find the smallest and largest digit in the number

question, we will generate a 4-digit random number between 1000 – 9999 and completeUse at least one constant variable to store value in the program.Following are 2 sample screen shots to illustrate the expected behavior of yourprogram.

Note:4

© May not be copied or duplicatedwithout the permission of the owner.Figure 3 – Sample output #2 for Question 2

Question #3: New Word Program (6 pts) Your program should behave as follow:

  1. Display a welcome message.
  2. Ask the user to prompt 3 words with at least 1 letter.
  3. Ask the user to prompt 3 numbers, that should be less than the length of eachword to indicate length of substring in each word. For example, if the word is

Ann, then the entered number should be less than 3 (the length of Ann).

  1. Display the resulting new word.
  2. Display a farewell message, so that the user knows that the program has

terminated normally.Restriction: This questions requires the use of the functions: length(), substr().Assumption: Assume a perfect user who will always enter the correct input values.Following are two sample screen shots to illustrate the expected behavior of yourprogram. Your program is to work with any words entered by the user.last n characters. Concatenate the three resulting substrings into a singlenew word.

  1. For each word, create a new substring by taking the first n characters and theWrite a program that prompts the user for three words.5

© May not be copied or duplicatedwithout the permission of the owner.Figure 4 – Sample output #1 for Question 3Figure 5 – Sample output #2 for Question 36

© May not be copied or duplicatedwithout the permission of the owner.

Submitting Assignment 1

- Naming convention for zip file to submit: Create one zip file, containing all sourcefiles (.cpp files only) for your assignment. The zip file should be called

a#_studentID, where # is the number of the assignment and studentID is your

student ID number. For example, for the first assignment, student 123456 would

submit a zip file named a1_123456.zip. (See instructions on how to zip fileswhich are posted in the Assessment section of the eConcordia course webpage.)- Submit only ONE version of an assignment.- Late assignments will be discounted by 25%. Late assignments are accepted up

to five days late (grace period) and weekends count.Evaluation Criteria for Assignment 1 (20 pts)

Question #13 pts.Question #26 pts.Question #36 pts.

Format/clarity/completeness/accuracyof output

1 pt.

4 pts.

2 pts.

Proper use of required C++ concepts

2 pts.

2 pts.

4 pts.

For all 3 questions of assignment 1 – 5 pts.Comments – description of variables / description of the steps in code

/ purpose of program2 pts.Choice of variable names

1 pt.Indentation and readability of program2 pts.

标签:Fundamentals,COMP,Object,Question,number,program,output,pts,your
From: https://www.cnblogs.com/wx--codinghelp/p/18436978

相关文章

  • Java中常用类之Object类
    Object类中的常用方法:1.hashCode方法,是对象地址值的另一种表现形式classStudent{Stringname;intage;publicStudent(){}publicStudent(Stringname,intage){this.name=name;this.age=age;}}测试类中是这样进......
  • 【基础岛·第6关】OpenCompass 评测 InternLM-1.8B 实践
    目录1.概览2.环境配置2.1创建开发机和conda环境2.2安装——面向GPU的环境安装3.数据准备3.1评测数据集3.2InternLM和ceval相关的配置文件4.启动测评4.1使用命令行配置参数法进行评测4.2使用配置文件修改参数法进行评测1.概览在OpenCompass中评估一个模型通常包括......
  • Qt - QObject设置对象名称和属性
    作用用来作为id选择器和属性选择器,来设置样式setObjectName方法用来设置对象的名字,不同对象可以重复label=QLabel()label.setObjectName("label")objectName方法获取对象的名字QStringstrobj=this->objectName();qDebug()<<"strobj="<<strobj;setProperty方法......
  • 《破晓传说》d3dcompiler_43.dll缺失启动遇阻?d3dcompiler_43.dll丢失问题全解析与解决
    《破晓传说》在启动过程中遇到d3dcompiler_43.dll缺失的问题,确实会导致游戏无法正常运行。这个问题通常与DirectX组件的完整性或兼容性有关。以下是对d3dcompiler_43.dll丢失问题的全解析与解决方案:问题解析d3dcompiler_43.dll是什么?d3dcompiler_43.dll是DirectX的一部分,它......
  • COMP90049, Introduction to Machine Learning
    SchoolofComputingandInformationSystemsTheUniversityofMelbourneCOMP90049,IntroductiontoMachineLearning,Semester22024Assignment2:PredictingSupremeCourtRulingsReleased:Friday,September6th2024.Due:StageI:Friday,October4th5pm......
  • 学习011-03-03 Relationships Between Persistent Objects in Code and UI(代码和用户
    RelationshipsBetweenPersistentObjectsinCodeandUI(代码和用户界面中持久对象之间的关系)Whendesigningabusinessmodel,itcanbenecessarytosetspecificrelationshipsbetweenbusinessobjects.Thistopicdescribeshowtosettheserelationshipsbe......
  • composition API 优势好处特点
    3.1、为什么要选择组合式API?由于vue2有局限性:组件的逻辑膨胀导致组件的可读性变差;无法跨组件重用代码;vue2对TS的支持有限3.2、组合式API解决了什么问题?面对vue2的局限性,可以将相同的代码组织在一起,而不会散落在各个角落3.3、组合式API的优点?compositionAPI是根据逻辑相关性组织代......
  • 7-2 jmu-Java-04面向对象进阶-01-接口-Comparable
    编写实现Comparable接口的PersonSortable类,使其按name以及age排序1.编写PersonSortable类属性:privatename(String)、privateage(int)有参构造函数:参数为name,agetoString函数:返回格式为:name-age实现Comparable接口:实现先对name升序排序,如果name相同则对age进行升序排序......
  • AttributeError: ‘ImageDraw‘ object has no attribute ‘textsize‘
    在进行画框的时候发现代码报错了,查询原因后发现我的pillow版本删除了该方法有两种处理办法:1、就是降低版本2、就是根据新版本修改代码,我这里主要来介绍一下新版本如何修改代码,把textsize改为textbbox首先先了解一下原先这个textsize方法的作用查看官方文档给的示例 from......
  • Docker Compose 学习笔记
    DockerCompose学习笔记DockerCompose安装安装完DockerEngine后,以插件方式安装DockerCompose:设置安装源sudoyuminstall-yyum-utilssudoyum-config-manager--add-repohttps://download.docker.com/linux/centos/docker-ce.repo安装Composepluginsudo......