1 CSC 101 Computer Science 1 – Fall 2021 Student Name: ________________________________________________ School ID: _____________________ Section Number: ______________ Sections: • H004 Test Breakdown...

1 answer below »
need assignment completed


1 CSC 101 Computer Science 1 – Fall 2021 Student Name: ________________________________________________ School ID: _____________________ Section Number: ______________ Sections: • H004 Test Breakdown Concept Knowledge 60 % Program Analysis 25 % Program Writing 15 % Last Name:____________________ 2 Grade: ________________________________ Concept Knowledge Match the following definitions and statements to the terms listed on the right. Note that some terms may be used more than once while others may not be used at all. (3 pts each) ___________ 1. In this stage of the Waterfall model, the app is planned, and the software requirements are mapped out. A. Logical B. Release C. Pre-Test D. Body E. Prototype F. Sentinel Controlled Loop G. Plan H. Local Variable I. Syntax J. Pre-defined function K. Post-Test L. Return Type M. Pseudocode N. Develop O. Void P. Condition/Expression Q. Test R. Flowchart S. Parameter T. Initialization U. Runtime V. Design W. Global Variable X. Count Controlled Loop Y. Step ___________ 2. This type of error occurs when the operating system/computer cannot execute a line of code in a program. ___________ 3. This is the phase of a for loop where the counting variable in initialized/created. ___________ 4. This type of design approach involves creating a high level/informal description of a program that does not adhere to any particular programming language’s rules. ___________ 5. This type of loop repeats as long as the user needs to enter input. ___________ 6. This type of function is one that is already defined in C++ and is ready to use. Last Name:____________________ 3 ___________ 7. A do while loop is called this due to the fact that the body executes first rather than the expression. ___________ 8. This allows us to redefine the scope of a function so that we may define it below main. ___________ 9. In this stage of the Waterfall Model, the app is checked and executed to ensure there are no errors in the program. ___________ 10. This type of variable is one that can be used throughout the entire program. ___________ 11. This type of loop repeats from a starting number to an ending number, repeating a quantifiable number of times. ___________ 12. This is a type of variable that a function uses to store its input. ___________ 13. This phase of a for loop is where the counter variable is updated/changed. ___________ 14. This type of error occurs when the code written in a program does not follow the language’s syntactical rules. ___________ 15. This will make a function one that returns nothing back to where its called. Last Name:____________________ 4 16. Briefly describe 2 reasons why need functions. (6 pts) 17. List the stages of the for loop in the order that they execute and indicate whether each will repeat on each round of the loop. (4 pts) 18. Describe an example of a syntactical error. Also describe an example of a logical error. (5 pts) Last Name:____________________ 5 Analysis 19. The following program has a total of 5 errors in it. List the line number of each error and determine whether the error is a syntax or logical error. (5 pts) Line 01: int larger(int a, int b); Line 02: Line 03: Line 04: int main() Line 05: { Line 06: int a, int b, int c, int d, int e, int f; Line 07: Line 08: cout < "enter="" 4="" numbers:="" ";="" line="" 09:="" cin="">< a="">< b="">< c="">< d="">< e="">< f;="" line="" 10:="" line="" 11:="" cout="">< "number="" 1:="" "="">< larger(a,="" f)="">< "\n";="" line="" 12:="" cout="">< "number="" 2:="" "="">< larger(b,="" c)="">< "\n";="" line="" 13:="" cout="">< number="" 3:="">< larger(f,="" d)="">< "\n";="" line="" 14:="" cout="">< "number="" 3:="" "="">< larger(c,="" b)="">< "\n";="" line="" 15:="" cout="">< "number="" 5:="" "="">< larger(a,="" a)="">< "\n";="" line="" 16:="" }="" line="" 17:="" line="" 18:="" int="" larger(int="" a,="" int="" b)="" line="" 19:="" {="" line="" 20:="" if="" (a="">< b)="" line="" 21:="" return="" a;="" line="" 22:="" else="" line="" 23:="" return="" b;="" line="" 24:="" }="" sample="" output="" last="" name:____________________="" 6="" 20.="" read="" the="" following="" program="" and="" indicate="" the="" scope="" of="" each="" variable="" and="" function="" in="" it.="" identify="" whether="" each="" is="" local="" or="" global="" scope.="" (6="" pts)="" line="" 01:="" int="" t="20;" line="" 02:="" int="" function_a(int="" x,="" int="" y);="" line="" 03:="" line="" 04:="" int="" main()="" line="" 05:="" {="" line="" 06:="" int="" j="2;" line="" 07:="" line="" 08:="" double="" l;="" line="" 09:="" line="" 10:="" for="" (int="" i="0;" i="">< 10;="" i++)="" line="" 11:="" {="" line="" 12:="" j="0;" line="" 13:="" line="" 14:="" do="" line="" 15:="" {="" line="" 16:="" j="" +="2;" line="" 17:="" line="" 18:="" int="" d;="" line="" 19:="" cin="">> d; Line 20: Line 21: l = d; Line 22: Line 23: } while (j < 10);="" line="" 24:="" }="" line="" 25:="" line="" 26:="" int="" r="function_a(j," l);="" line="" 27:="" line="" 28:="" cout="">< r="">< "="" "="">< t="">< "\n";="" line="" 29:="" }="" line="" 30:="" line="" 31:="" int="" function_a(int="" x,="" int="" y)="" line="" 32:="" {="" line="" 33:="" int="" z="0;" line="" 34:="" line="" 35:="" for="" (int="" p="x;" p="">< y;="" p++)="" line="" 36:="" {="" line="" 37:="" t="" +="z;" line="" 38:="" z="p" +="" x="" -="" y;="" line="" 39:="" }="" line="" 40:="" return="" z;="" line="" 41:="" }="" last="" name:____________________="" 7="" 21.="" read="" the="" following="" snippets="" of="" code,="" which="" all="" contain="" loops.="" determine="" the="" loop="" control="" variable="" in="" each="" loop="" and="" indicate="" the="" type="" of="" lcv="" it="" is,="" as="" well="" as="" the="" value(s)="" that="" the="" lcv="" would="" need="" to="" be="" for="" the="" loop="" to="" terminate.="" (6="" pts)="" code="" a="" int="" i="4;" while="" (i="">< 10)="" {="" i="" +="2;" cout="">< i="">< ",="" ";="" }="" cout="">< "\n";="" code="" c="" bool="" is_over="false;" int="" x="34," y="78;" int="" n;="" do="" {="" cout="">< "enter="" a="" number="" to="" add:="" ";="" cin="">> n; x += n; if (x >= 78) is_over = true; } while(is_over == false); Code B int sum = 0; int m = 0; while(m >= 0) { cin >> m; sum += m; } Last Name:____________________ 8 22. Read the following code: a. Indicate the starting value of the counter for this for loop. (1 pt) b. Indicate the ending value of the counter for this for loop. (1 pt) c. What is the output of this for loop? You only must output result up to 40. (3 pts) d. What is the purpose of this program? (3 pts) for(int num = 0; num < 100;="" num++)="" {="" if="" (num="" %="" 5="=" 0="" ||="" num="" %="" 7="=" 0)="" cout="">< num="">< ",="" ";="" }="" last="" name:____________________="" 9="" programming="" problem="" 23.="" the="" following="" is="" a="" partially="" complete="" program="" that="" computes="" the="" total="" tax="" on="" a="" set="" of="" land,="" measured="" in="" acres,="" by="" implementing="" a="" function="" called="" calc_tax.="" complete="" the="" program="" by="" filling="" in="" the="" missing="" lines="" of="" code.="" comments="" have="" been="" left="" above="" each="" blank="" that="" give="" hints="" as="" to="" what="" should="" be="" entered.="" sample="" output="" of="" the="" correctly="" completed="" program="" is="" given="" below.="" 1.="" write="" a="" prototype="" for="" the="" calc_tax="" function="" that="" is="" defined="" after="" main.="" hint:="" complete="" part="" 3="" before="" you="" complete="" this="" part.="" _______________________________________________________________="" int="" main()="" {="" double="" price_acre;="" ask="" the="" user="" for="" the="" price="" of="" 1="" acre="" cout="">< "what="" is="" the="" price="" per="" acre?="" ";="" cin="">> price_acre; //Loop from 1 to 20 using a count-controlled loop for (int i = 1; i <= 20;="" i++)="" {="" format="" the="" number="" output="" to="" 2="" decimal="" places.="" cout="">< setprecision(2)="">< fixed; //2. output the number of acres (i.e., i) and the total tax //owed on the acres. look at the sample output at the end //of the program for how the output should be formatted. //call the calc_tax function and pass in “i” for the acres //and “price_acre” for the number of acres. //hint: complete part 3 before completing this part. __________________________________________________________ __________________________________________________________ } } last name:____________________ 10 //3. begin the definition of a function called calc_tax. the tax //should output the total tax owed and create the following //parameters: // acres as decimal number // price_per_acre as a decimal number. ______________________________________________________________ { //get the total monetary worth of the land. double acres_worth = acres * price_per_acre; //assessment value is 60% of the acres total worth; double assessment_value = acres_worth * 0.6; //total the tax amount, 73 cents per 100 acres. double tax = 0; //4. write a for loop header that would iterate as follows: //start: 0 //end: assessment_value //increase the counter variable by 100. ________________________________________________________ { tax += 0.73; } //5. output the calculated tax fixed;="" 2.="" output="" the="" number="" of="" acres="" (i.e.,="" i)="" and="" the="" total="" tax="" owed="" on="" the="" acres.="" look="" at="" the="" sample="" output="" at="" the="" end="" of="" the="" program="" for="" how="" the="" output="" should="" be="" formatted.="" call="" the="" calc_tax="" function="" and="" pass="" in="" “i”="" for="" the="" acres="" and="" “price_acre”="" for="" the="" number="" of="" acres.="" hint:="" complete="" part="" 3="" before="" completing="" this="" part.="" __________________________________________________________="" __________________________________________________________="" }="" }="" last="" name:____________________="" 10="" 3.="" begin="" the="" definition="" of="" a="" function="" called="" calc_tax.="" the="" tax="" should="" output="" the="" total="" tax="" owed="" and="" create="" the="" following="" parameters:="" acres="" as="" decimal="" number="" price_per_acre="" as="" a="" decimal="" number.="" ______________________________________________________________="" {="" get="" the="" total="" monetary="" worth="" of="" the="" land.="" double="" acres_worth="acres" *="" price_per_acre;="" assessment="" value="" is="" 60%="" of="" the="" acres="" total="" worth;="" double="" assessment_value="acres_worth" *="" 0.6;="" total="" the="" tax="" amount,="" 73="" cents="" per="" 100="" acres.="" double="" tax="0;" 4.="" write="" a="" for="" loop="" header="" that="" would="" iterate="" as="" follows:="" start:="" 0="" end:="" assessment_value="" increase="" the="" counter="" variable="" by="" 100.="" ________________________________________________________="" {="" tax="" +="0.73;" }="" 5.="" output="" the="" calculated="">
Answered Same DayNov 06, 2021

Answer To: 1 CSC 101 Computer Science 1 – Fall 2021 Student Name:...

Neha answered on Nov 07 2021
127 Votes
CSC 101 Computer Science 1 –
Fall 2021
    Student Name:
         
    
School ID:
    
    
    
Section Number:
    
    
    
    Sections:
· H004
Test Breakdown
    Concept Knowledge
    60 %
    Program Analysis
    25 %
    Program Writing
    15 %
(
1
)
Grade:     
Concept Knowledge
Match the following definitions and statements to the terms listed on the right. Note that s
ome terms may be used more than once while others may not be used at all. (3 pts each)
    
Design    
    
1.
    
In this stage of the Waterfall model, the app is planned, and the software requirements are mapped out.
    A. Logical
B. Release
C. Pre-Test
D. Body
E. Prototype
F. Sentinel Controlled Loop
G. Plan
H. Local Variable
I. Syntax
J. Pre-defined function
K. Post-Test
L. Return Type
M. Pseudocode
N. Develop
O. Void
P. Condition/Expression
Q. Test
R. Flowchart
S. Parameter
T. Initialization
U. Runtime
V. Design
W. Global Variable
X. Count Controlled Loop
Y. Step
    
Runtime    
    
2.
    
This type of error occurs when the operating system/computer cannot execute a line of code in a program.
    
    
Initialization
    
3.
    
This is the phase of a for loop where the counting variable in initialized/created.
    
    
Pseudocode
    
4.
    
This type of design approach involves creating a high level/informal description of a program that does not adhere to any particular programming language’s rules.
    
    
Sentinal Controlled Loop
    
5.
    
This type of loop repeats as long as the user needs to enter input.
    
    
Pre-defined function
    
6.
    
This type of function is one that is already defined in C++ and is ready to use.
    
(
Last

Name:

)
(
10
)
     True
    7.
    A do while loop is called this due to the fact that the body executes first
rather than the expression.
    
Predefined function
    
8.
    This allows us to redefine the scope of a function so that we may define it below main.
    
Test    
    
9.
    In this stage of the Waterfall Model, the app is checked and executed to ensure there are no errors in the program.
     Global variable
    10.
    This type of variable is one that can be used throughout the entire program.
    
Count controlled loop
    
11.
    This type of loop repeats from a starting number to an ending number, repeating a quantifiable number of times.
     Local variable
    12.
    This is a type of variable that a function uses to store its input.
    Condition     
    13.
    This phase of a for loop is where the counter variable is updated/changed.
    
Syntax error    
    
14.
    This type of error occurs when the code written in a program does not
follow the language’s syntactical rules.
     Return type
    15.
    This will make a function one that returns nothing back to where its called.
16. Briefly describe 2 reasons why need functions. (6 pts)
· The first reason is usability will stop once the function is defined we can use it again and again. We can invoke the same function multiple times in the program.
· Another reason is abstraction. If we want to use a particular function then it is important that we know the name of the function, it's working, arguments and the type of result which it is returning. Rest of the things needs to be hidden and abstraction helps to do that.
17. List the stages of the for loop in the order that they execute and indicate whether each will repeat on each round of the loop. (4 pts)
· The first stage is initialization. In this stage we introduce the variables which will be used in the program and the variables are initialized as zero or one.
· Test condition is second stage in which one of the counter...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here