Part I. Written Assignment

1.What arguments can you make for the idea of a single language for all programming domains?

2.What arguments can you make against the idea of a single language for all programming domains?

3.What are the arguments for writing efficient programs even though hardware is relatively inexpensive?

4.Many contemporary languages allow two kinds of comments: one in which delimiters are used on both ends (multiple-line comments), and one in which a delimiter marks only the beginning of the comment (one-line comments). Discuss the advantages and disadvantages of each of these with respect to our criteria.

5.Some programming languages are typeless. What are the obvious advantages and disadvantages of having no types in a language?

6.Assume the following JavaScript program was interpreted using static-scoping rules. What value of x is displayed in function sub1? Under dynamic-scoping rules, what value of x is displayed in function sub1?

var x;
function sub1() {
document.write("x = " + x + "
");
}
function sub2() {
var x;
x = 10;
sub1();
}
x = 5;
sub2();

7.Consider the following JavaScript program:

var x, y, z;
function sub1() {
var a, y, z;
function sub2() {
var a, b, z;
...
}
...
}
function sub3() {
var a, x, w;
...
}

List all the variables, along with the program units where they are declared, that are visible in the bodies of sub1 , sub2 , and sub3 , assuming static scoping is used.

8.Consider the following C program:

void fun(void) {
int a, b, c; /* definition 1 */
...
while (...) {
int b, c, d; /*definition 2 */
... <---------------- 1
while (. . .) {
int c, d, e; /* definition 3 */
... <---------------- 2
}
... <---------------- 3
}
... <---------------- 4
}

For each of the four marked points in this function, list each visible variable, along with the number of the definition statement that defines it.

Part II: programming exercise on Computing Mortgages

The goal of this exercise is simply to practice with the basic imperative features of C++ (or Java). In later assignments we will assume the student has mastered the basic features of some advanced techniques, and will focus on the appropriate use of objects and inheritance.

Write a program that lets the user input a loan amount and starting annual interest rate (not monthly interest rate), then display the monthly and total payments. Print a table that displays the monthly and total payments for 4 interest rates, with an increment of starting from the given starting interest rate for the years from 1 to 10 (if pay off the mortgage in that number of years.)

Sample Output:

Enter the loan amount: 10000
Enter the starting interest rate: 5.0
Years Interest Rate Monthly Payment Total Payment
1 5% 856.07 10272.89
5.5% 858.36 10300.41
6.0% 860.66 10327.97
6.5% 862.96 10355.57
2 5% 438.71 10529.13
5.5% 440.95 10582.95
6.0% 443.2 10636.94
6.5% 445.46 10691.1
… …
10 5% 106.06 12727.86
5.5% 108.52 13023.15
6.0% 111.02 13322.46
6.5% 113.54 13625.75
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.