CIS111 Chapter 14 Homework For this homework, write a query that will solve the mathematical questions. You can use CIS111_AP database. Each question is worth 5 points, for a total of 10 points....

1 answer below »
e


CIS111 Chapter 14 Homework For this homework, write a query that will solve the mathematical questions. You can use CIS111_AP database. Each question is worth 5 points, for a total of 10 points. Upload your answers to this sheet, and the query to Moodle. You could also put the answers in a block comment within your script. Use comments within your code to explain each operation. Question 1. Assume you have the following mathematical operation: SELECT .9868596234 * 4589.614689 The result for the above calculation is 4529.3054235376481226 A. What is the precision for the result? ______________ digits B. What is the scale for the result? ______________ digits Question 2 Write a query that will hold the original equation (not the answer) in a variable, then, using that variable, Output result of the calculation (using the convert function) in the following data types. Data Type Result A. Integer _______________________________ B. Decimal(15,8) _______________________________ C. Real(7 sig.) _______________________________ D. Float(15 sig.) _______________________________ USE CIS111_AP /*Question 1. Assume you have the following mathematical operation: .9868598596234 * 4589.6314689 The result for the above calculation is 4529.32198294344281226 What is the precision for 4529.32198294344281226? _______21_________ digits What is the scale for 4529.32198294344281226?_ ______17_________ digits */ /*Question 2 Record the value of the question 1 mathematical operation, if the result of the calculation is stored in the following data types: */ /* Declare a variable */ DECLARE @Answer decimal(21,17); SET @Answer = .9868598596234 * 4589.6314689; --Data Type Result --Integer ____ 4529 _____ SELECT CAST(@Answer AS INT) AS INT1a, CONVERT(INT, @Answer) AS INT1b, --Decimal(15,8) ___ 4529.32198294___________________ CAST(@Answer AS Decimal(15,8)) AS Decimal1a, CONVERT(Decimal(15,8), @Answer)AS Decimal1b, --Real(7 sig.) __________ 4529.322______________(NUMBERS – 1 – 24)_______ CAST(@Answer AS REAL(7)) AS Real1a, CONVERT(REAL(7), @Answer) AS Real1b, --Float(15 sig.) _____ 4529.32198294344_________(NUMBERS 25 – 53)_________________ CAST(@Answer AS FLOAT(25)) AS Float1a, CONVERT(FLOAT(25), @Answer) AS Float1b --Decimal(15,12) ______ Arithmetic overflow error converting numeric to data type numeric --CAST(@Answer AS Decimal(15,12)) AS Decimal3, --CONVERT(Decimal(15,12), @Answer) AS Decimal4 GO USE CIS111_AP /* Chapter 14 homework Bob James */ -- declare and set variable for this batch DECLARE @Answer decimal(21,17) SET @Answer = .9868598596234 * 4589.6314689 -- Now convert the answer SELECT CAST(@Answer AS INT)AS INT2a, CONVERT(INT, @Answer) AS INT2b, CAST(@Answer AS Decimal(15,8))AS Decimal2a, CONVERT(Decimal(15,8), @Answer)AS Decimal2b, CAST(@Answer AS REAL(7))AS Real2a, CONVERT(REAL(7), @Answer)AS Real2b, CAST(@Answer AS FLOAT(25))AS Float2a, CONVERT(FLOAT(25), @Answer) AS Float2b --CAST(@Answer AS Decimal(15,12)), CONVERT(Decimal(15,12), @Answer) GO USE CIS111_AP /* Chapter 14 homework Bob James */ -- declare and set variable for this batch DECLARE @Answer decimal(17,13) SET @Answer = .9868598596234 * 4589.6314689 -- Now convert the answer SELECT CAST(@Answer AS INT) as CastINT, CONVERT(INT, @Answer) AS ConvINT, CAST(@Answer AS Decimal(15,8)) as CastDEC, CONVERT(Decimal(15,8), @Answer) as ConvDEC, CAST(@Answer AS REAL(7)) AS CastReal7, CONVERT(REAL(15), @Answer) as ConvReal15, CAST(@Answer AS FLOAT(25)) as CastFloat25, CONVERT(FLOAT(25), @Answer) as ConvFloat25 Q 1. Assume you have the following mathematical operation: .9868598596234 * 4589.6314689 The result for the above calculation is 4529.32198294344281226 What is the precision and scale for .9868598596234? _______13_________ digits What is the precision and scale for 4589.6314689? _____17_________ digits Q 2 Record the value of the question 1 mathematical operation, if the result of the calculation is stored in the following data types: Data Type Result Integer ____ 4529 _____ SELECT CAST(4529.32198294344281226 AS INT) SELECT CONVERT(INT, 4529.32198294344281226) Decimal(15,8) ___ 4529.32198294___________________ SELECT CAST(4529.32198294344281226 AS Decimal(15,8)) SELECT CONVERT(Decimal(15,8), 4529.32198294344281226) Real(7 sig.) __________ 4529.322______________(NUMBERS – 1 – 24)_______ SELECT CAST(4529.32198294344281226 AS REAL(7)) SELECT CONVERT(REAL(7), 4529.32198294344281226) Float(15 sig.) _____ 4529.32198294344_________(NUMBERS 25 – 53)_________________ SELECT CAST(4529.32198294344281226 AS FLOAT(25)) SELECT CONVERT(FLOAT(25), 4529.32198294344281226) Decimal(15,12) ______ Arithmetic overflow error converting numeric to data type numeric SELECT CAST(4529.32198294344281226 AS Decimal(15,12)) SELECT CONVERT(Decimal(15,12), 4529.32198294344281226) USE CIS111_AP /* Chapter 14 homework Bob James */ -- declare and set variable DECLARE @Answer decimal(17,13) SET @Answer = .9868598596234 * 4589.6314689 print @Answer SELECT CAST(@Answer AS INT), CONVERT(INT, @Answer), CAST(@Answer AS Decimal(15,8)), CONVERT(Decimal(15,8), @Answer), CAST(@Answer AS REAL(7)), CONVERT(REAL(7), @Answer), CAST(@Answer AS FLOAT(25)), CONVERT(FLOAT(25), @Answer) --CAST(@Answer AS Decimal(15,12)), CONVERT(Decimal(15,12), @Answer) USE CIS111_AP /* Chapter 14 homework Bob James */ -- declare and set variable DECLARE @Answer decimal(17,13) SET @Answer = .9868598596234 * 4589.6314689 print @Answer SELECT CAST(@Answer AS INT) as CastINT, CONVERT(INT, @Answer) AS ConvINT, CAST(@Answer AS Decimal(15,8)) as CastDEC, CONVERT(Decimal(15,8), @Answer) as ConvDEC, CAST(@Answer AS REAL(7)) AS CastReal7, CONVERT(REAL(15), @Answer) as ConvReal15, CAST(@Answer AS FLOAT(25)) as CastFloat25, CONVERT(FLOAT(25), @Answer) as ConvFloat25
Answered Same DayApr 22, 2022

Answer To: CIS111 Chapter 14 Homework For this homework, write a query that will solve the mathematical...

Shweta answered on Apr 22 2022
92 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here