GSP115 Week 1 Assignment: Part A,B,C with Visual Studio 2012 source code, answers, word document and screenshots – Instant Delivery – Perfect Solution

Lab Price = $10
Please feel free to send us your queries at: [email protected]
Payment methods

Add to Cart

Buy Now

View Cart


Problem Statement

Week 1: Simple Data Types
Instructions
Complete the following assignments. Cut and paste your finished code into a Word document, clearly identifying which assignment it is. Also, capture the output of the program and paste that into the Word document. If there are questions to be answered, put the answers after the output. When you complete all three of this week’s assignments, save the document as yourLastName_GSP115_W1_Assignments.docx. Submit it to the Week 1 assignment Dropbox.
1. Compile Time Bugs (TCO 4)
Find and fix the four (possibly five) compile time bugs in the code at the end of this section. Compile time bugs shown as errors when you compile, but the Visual Studio IDE also gives you visual clues in the form of red squiggly underlines, as shown here . You will actually see more than five errors, but they are all caused by just four or five bugs. There is a case where you have either two bugs or one, depending on what you think the error is. In one case, it can be fixed with a single change. In the other case, it will take two changes to fix the problems.

Here is the code.
// Week 1 Assignment-1
// Description: Compile time errors with simple variables
//———————————-

//**begin #include files************
#include // provides access to cin and cout
//–end of #include files———–
//———————————-

//**begin global constants**********
// NO GLOBALS
//–end of global constants———
//———————————-

using namespace std;
//———————————-

//**begin main program**************
int main()
{
// Initialize variables
int 1IntVar;
int x = “Four”;
char y = “a”;
float z1 = 4.756f
z2 = 7.45f;
// Print out the values
1IntVar = x;
cout << "1IntVar = " << 1IntVar << endl; cout << "x = " << x << endl; cout << "y = " << y << endl; cout << "z1 = " << z1 << endl; cout << "z2 = " << z2 << endl; ductTape; // Wait for user input to close program when debugging. cin.get(); return 0; } //--end of main program------------- //---------------------------------- 2. Numbers and Conversions (TCO 4) The following has one compile time bug. This bug only generates a warning in some compilers and would cause an exception during runtime. Visual Studio 2012 actually gives us an error at compile time. This is better, because you should never do the thing that causes this error. Fix the error and run the program. Compare the output to the code and answer the questions found after the code. Here is the code. // Week 1 Assignment-2 // Description: Numbers and conversions with simple variables //---------------------------------- //**begin #include files************ #include // provides access to cin and cout
#include
//–end of #include files———–
//———————————-

using namespace std;
//———————————-

//**begin main program**************
int main()
{
// create and initialize variables
int x, y;
float f1 = 1.6767676f;
float f2 = 2.2f;
float diff;
// demonstrate math and number output
x = y;
x = f1; // What happens when you store a float into an int?
y = f2; // Does it round or truncate?
// display ints
cout << "--->using default cout settings: ” << endl; cout << "x=" << x << " y=" << y << endl; cout << "f1=" << f1 << " f2=" << f2 << endl; cout << "--->using scientific settings: ” << endl; cout << scientific << "x=" << x << " y=" << y << endl; cout << scientific << "f1=" << f1 << " f2=" << f2 << endl; cout << "--->setting precision to 4″ << setprecision(4) << endl; cout << scientific << "x=" << x << " y=" << y << endl; cout << scientific << "f1=" << f1 << " f2=" << f2 << endl; cout << "--->using fixed settings: ” << endl; cout << fixed << "x=" << x << " y=" << y << endl; cout << fixed << "f1=" << f1 << " f2=" << f2 << endl; cout << "--->setting precision to 12″ << setprecision(12) << endl; cout << fixed << "x=" << x << " y=" << y << endl; cout << fixed << "f1=" << f1 << " f2=" << f2 << endl; cout << "--->restoring float (default) settings: ” << endl; cout << defaultfloat << "x=" << x << " y=" << y << endl; cout << "f1=" << f1 << " f2=" << f2 << endl; cout << "--->setting precision to (default) 6″ << setprecision(6) << endl; cout << "x=" << x << " y=" << y << endl; cout << "f1=" << f1 << " f2=" << f2 << endl; cout << "-----> Showing results of unusual and unexpected math operations ” << endl; f2 = sqrt(f1);// take the square root of f1 cout << "The square root of " << f1 << " is " << f2 << endl; f2 = f2*f2; // square the square root of f1 cout << "Squaring f2 should give us the same value as f1. f1 = " << f1 << " f2 = " << f2 << endl; diff = f1 - f2; // This should be zero--is it? cout << "diff should be zero. diff = " << diff << endl; cout << "Oops. Let's take another look at f1 and f2 in higher precision."<< endl; cout << "--->setting precision to 12 places. f1 = ” << setprecision(12) << f1 << " f2 = " << f2 << endl; f2 = f2/diff; // What happens when we divide a floating point by something close to zero? cout << "Division by a very small number. f2 = " << f2 << endl; f1 = f1/0.0; // What happens when we actually divide by zero? cout << "Division by zero. f1 = " << f1 << endl; f1 = f1 * diff; cout << "Multiply a small negative number by infinity. f1 = " << f1 << endl; // Wait for user input to close program when debugging. cin.get(); return 0; } //--end of main program------------- //---------------------------------- Questions 1. When storing a floating point number into an integer variable, does it truncate or round? 2. When the floating point numbers were printed out at higher precision, they were not the same value as entered. Research this issue and explain why. 3. The setprecision(12) command either sets the precision for 12 places after the decimal point or 12 digits total; select the right option for each case below. a. fixed [total/after the decimal point] b. scientific [total/after the decimal point] c. float [total/after the decimal point] 4. Based on the results of taking the square root and then squaring again, what would you say about the accuracy of floating point arithmetic in C++? 5. Dividing by zero in earlier compilers generates an error and an exception. What does Visual Studio 2012 produce as the result of dividing by zero? 3. Create a Program From Pseudocode (TCO 1) This exercise will be to use pseudocode (in the form of comments) to write a program that creates and initializes the variables for a computer role-playing game character generator. This will only set up the variables. It is slightly different from our iLab assignment. You can make up your own variable names. Here is the pseudocode. // Week 1 Assignment-3 // Description: Setup Variables for CRPG Character Generator //---------------------------------- //**begin #include files************ #include // provides access to cin and cout
//–end of #include files———–
//———————————-

//**begin global constants**********

//–end of global constants———
//———————————-

using namespace std;
//———————————-

//**begin main program**************
int main()
{
//**Enter code staring here
// Create Variables
// character ID [integer] initialized to 0
// strength [integer] initialized to 80
// armor [integer] initialized to 70
// health [float] initialized to 1.0f
// flag to indicate if the character is dead or alive [Boolean] initialized to true
// Print out each of the variables.
//**End of your code
// Wait for user input to close program when debugging.
cin.get();
return 0;
}
//–end of main program————-
//———————————-

Relevant Material
Screenshots
Assignment1: Part C
Assignment1: Part C

Assignment1: Part B Answers
Assignment1: Part B Answers
Assignment1: Part B
Assignment1: Part B

Assignment1: Part A
Assignment1: Part A
Instructions
* If you want to purchase multiple products then click on “Buy Now” button which will give you ADD TO CART option.Please note that the payment is done through PayPal.
* You can also use 2CO option if you want to purchase through Credit Cards/Paypal but make sure you put the correct billing information otherwise you wont be able to receive any download link.
* Your paypal has to be pre-loaded in order to complete the purchase or otherwise please discuss it with us at [email protected].
* As soon as the payment is received, download link of the solution will automatically be sent to the address used in selected payment method.
* Please check your junk mails as the download link email might go there and please be patient for the download link email. Sometimes, due to server congestion, you may receive download link with a delay.
* All the contents are compressed in one zip folder.
* In case if you get stuck at any point during the payment process, please immediately contact us at [email protected] and we will fix it with you.
* We try our best to reach back to you on immediate basis. However, please wait for atleast 8 hours for a response from our side. Afterall, we are humans.
* Comments/Feedbacks are truely welcomed and there might be some incentives for you for the next lab/quiz/assignment.
* In case of any query, please donot hesitate to contact us at [email protected].
* MOST IMPORTANT Please use the tutorials as a guide and they need NOT to be used for any submission. Just take help from the material.
******************************************** Good Luck ***************************************************
Privacy Policy
We take your privacy seriously and will take all measures to protect your personal information.
Any personal information received will only be used to fill your order. We will not sell or redistribute your information to anyone.
Refund Policy
Incase you face any issues with the tutorial, please free to contact us on [email protected]
We will try our best to resolve the issue and if still persists we can discuss for a refund in case its required.
Payment Details
Lab Price = $10
Please feel free to send us your queries at: [email protected]

Payment methods

Add to Cart

Buy Now

View Cart

Leave a Reply