programs and data

109
Programs and Data

Upload: gigi

Post on 23-Feb-2016

56 views

Category:

Documents


0 download

DESCRIPTION

Programs and Data. Topics. Data. Simple data types. Variables and constants. Declarations. Assignment. Input and output. Style. Objectives. At the completion of this topic, students should be able to:. Describe the way that data is stored in the computer. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Programs and Data

Programs and Data

Page 2: Programs and Data

Topics

Simple data typesVariables and constantsDeclarationsAssignmentInput and outputStyle

Data

Page 3: Programs and Data

ObjectivesAt the completion of this topic, students should be able to:

Create proper identifiers in a C# programDescribe the difference between an object and simple dataDescribe the simple data types in the C# languageWrite C# programs that correctly• use declarations• use assignment statements• use literal data• use the Console class• format simple floating point data

Describe the object model of programming Describe the way that data is stored in the computer

Page 4: Programs and Data

Central to the idea of how a program works is the concept of data.

Every program you will ever write will deal withsome kind of data.

Data

Page 5: Programs and Data

That data might be …

• An image• Some music• A person’s name• A person’s age• A table of temperatures by week• A list of scores for a gymnastic event• A model of a molecule• A model of a character in a game• etc

Page 6: Programs and Data

We can imagine computer memory to be something likea set of post office boxes.

Data is stored in the computer’s memory.

Page 7: Programs and Data

Some boxeshold small things(like integers)

Some boxeshold larger things(like real numbers)

Some boxes holdreally big things(like objects)

and each boxhas an address

Page 8: Programs and Data

When we write a program, we need to reserve spacein memory for any data that the program will use.

We do this by giving thedata a name and tellingthe computer what kind of data it is.

The computer translates thisname into an address.

Page 9: Programs and Data

In order to be able to refer to the data stored at some address in the computer, we give the data at thataddress a name. These names are called identifiers.

12

X000054EA – hex address

Page 10: Programs and Data

IdentifiersThe name that you use to refer to a piece of dataor a method in C# is called an identifier.

A C# identifier must begin with either a letteror an underscore character i.e. [a-z A-Z _]

The remaining characters may be letters, digits, orthe underscore character[a-z A-Z 0-9 _]. All other characters are invalid.

Identifiers can be of any length.

Identifiers are case sensitive.

Page 11: Programs and Data

Some Valid Identifiersxx1_abcsumdata2oldValue

It is common in C# to run words togetherlike this. Just capitalize all words after the first.

Page 12: Programs and Data

Some Invalid Identifiers

123&change1_dollarmy-data

Page 13: Programs and Data

Good programmers selectnames that are meaningfuland somehow describe the

data that they name.

Page 14: Programs and Data

For example, we might have a piece of datathat represents the area of a circle.

x would be a bad choice to name that variableareaOfCircle would be a good choice

Page 15: Programs and Data

KeywordsC# has a set of built in keywords that are considered tobe part of the language. You cannot use any of these asidentifiers in your program. In Visual C# Express Edition, By default these will show up in blue. Examples include

boolbreakcharintdoubleclassconstdo…

Page 16: Programs and Data

Programs deal with all kinds of data.This data can be put into two broad categories.

Simple Datathe most basic forms of data - numbers and characters

Objectsmore complex data – made up of many pieces of simple data.For example, a person’s address is usually made up of a House number and a street name – 123 Main Street.

Page 17: Programs and Data

Every piece of data has a given size and shape and is stored at an address. The values that we store in a memory location must fit the size and shape that we specified for that address.

Page 18: Programs and Data

A Memory Chip

Page 19: Programs and Data

A Memory Chip

. . .00110001000110 . . .binary digits (bits)

Address:Where the data resides in memory

Size:How many bits make upthe data

Shape:How the data is coded

Page 20: Programs and Data

Number Systems

20

Page 21: Programs and Data

Decimal: Base 10In all number systems, each position represents a power of the base, where the rightmost digit is the multiplied by the base0, the next digit to the left is multiplied by base1, and so on.

So 352 can be expressed in powers of 10 as(3 * 102) + (5 * 101) + (2 * 100) = 300 + 50 + 2

21

Page 22: Programs and Data

Binary: Base 2In binary we only have two symbols with which to count, 0 and 1.

We call these binary symbols “bits”, short for “binary digits”.

If we group 8 of them together we have a byte, for example: 01001001.

What does this represent? Who knows? Maybe an integer, maybe a character, maybe an instruction or a pixel on your monitor or a tiny bit of music. 22

Page 23: Programs and Data

Binary: Base 2Since the base is 2, the place value represents a power of 2.

So a number like 1100 means…  (1 * 23) + (1 * 22) + (0 * 21) + (0 * 20) = 8 + 4 + 0 + 0 …which would translate to 12 in decimal

 

23

Page 24: Programs and Data

Hexadecimal: Base 16Here we need 16 unique symbols to count with, so 0 – 9 aren’t enough.

To fill in the remaining equivalents of 10 – 15 in decimal, we use the letters A – F.

So to count in hex, we use 0, 1, 2…8, 9, A, B, C, D, E, F. That gives us 16 unique symbols, where A16 = 1010, F16 = 1510 etc.

 Note that in documentation, we often express the base with a subscript, as in 3D2F16 (hex) or 10112 (binary).

24

Page 25: Programs and Data

Hexadecimal: Base 16In hex, an number like C416 means… (C * 161) + (4 * 160) + 

…which could be converted to decimal with (C * 16) + (4 * 1) = (1210 * 16) + 4 = 19610

(Note that the symbols 0 -9 have the same value in decimal and hex) 

25

Page 26: Programs and Data

Hexadecimal: Base 16The convenient thing about hex (which is not true of decimal) is that the base (16) is a power of 2, specifically 24

 As a result, hex is a concise shorthand for binary, because each hex digit represents four binary digits. 

 

26

Page 27: Programs and Data

Equivalent Values

Decimal Binary Hex

0 0000 0

1 0001 1

2 0010 2

3 0011 3

4 0100 4

5 0101 5

6 0110 6

7 0111 7

Decimal Binary Hex

8 1000 8

9 1001 9

10 1010 A

11 1011 B

12 1100 C

13 1101 D

14 1110 E

15 1111 F

27

Page 28: Programs and Data

Hexadecimal: Base 16For example, we would write the binary equivalent of decimal 12 as 11002, or C16. For large binary numbers (like memory addresses), it is more convenient to write the address in hex. So 0100 1011 0010 01012 can be shortened to 4B2516, which programmers often write as 0x4B25 or just x4B25.

That said, keep in mind that in memory, on your hard drive and on the Internet, binary is the only format that computers use! Decimal and hex are for humans!

28

Page 29: Programs and Data

Simple Data

Simple data elements all have a data typethat defines its size and shape and an identifierthat is an alias for its address in memory.

The data type defines the possible set of valuesthat a simple data element can have, and theoperations that can be performed on the data.

Page 30: Programs and Data

Simple Numeric Data Types

Type Storage Max Value

int 32 bits - 2,147,483,647 to 2,147,483,648double64 bits over 10308

The C# language defines a number of differentkinds of data. In this course we will mainly use thefollowing numeric data types:

Page 31: Programs and Data

Integer NumbersIntegers are whole numbers they have nofractional part.

Integer operations includeadditionsubtractionmultiplicationdivisionremainderassignment

Page 32: Programs and Data

Examples of Integers

10-53272,905,301

Page 33: Programs and Data

Real NumbersReal numbers have fractional partsReal numbers are often written in scientific format

The most common real data type is double

Operations on real numbers includeadditionsubtractiondivisionmultiplicationassignment

Page 34: Programs and Data

Examples of Real Numbers

10.5-5.02327.9812,905,301.0040.0000239897-1.56 X 10-4

Page 35: Programs and Data

Character Data

Different standards exist for encoding charactersThe ASCII standard, finalized in 1968, uses 7 bits for each character.In the ASCII standard, 1000001 is interpreted as the character ‘A’.The 8 bit ASCII standard was added later to increase the number ofpossible characters that could be encoded.

7 bits only allows for the definition of 128 unique characters. Subsequentstandards (ISO8859 and ISO10646) define much larger, multi-nationalcharacter sets. However, both are supersets of ASCII.

Character data is defined by the keyword char

When interpreted as a character, certain bit patternsrepresent printable characters and control characters.

Page 36: Programs and Data

The ASCII Code Table1st hex digit

2nd h

ex d

igit x41 = ‘A’

Page 37: Programs and Data

Character RepresentationCharacters are stored in the computer’s memory in ASCIIformat. For example, using the standard ASCII code, the character ‘A’ would be stored as 0100 0001. C# actually uses a superset of ASCII called Unicode, that supports a multiple byte character code and The character ‘A’ is stored as 0000 0000 0100 0001.

Page 38: Programs and Data

Characters

* Characters are written in C# programs as 'A', 'B', etc.* 'A' is stored as 0100 0001 in memory or hex 0X41 or dec 65* 'B' is stored as 0100 0010 in memory or hex 0X42 or dec 66* 'a' is stored as 0110 0001 in memory or hex 0X61 or dec 97* 'b' is stored as 0110 0010 in memory or hex 0X62 or dec 98

Page 39: Programs and Data

Control CharactersControl characters are characters that donot print, but cause some action, such as movingto a new line, to occur. In C# we write control characters as a backslash, followed by a characterthat denotes the action to be taken.

'\b' backspace'\t' tab'\n' new-line'\r' carriage return

Page 40: Programs and Data

Boolean Data

A piece of Boolean data can only have oneof two values:

truefalse

Boolean data is defined by the keyword bool

Page 41: Programs and Data

Variables and Constants

A variable is a name for a memory location (address)that holds some piece of data. The valuestored in that location may change duringexecution of the program; however, the typemay not.

A constant is a name for a memory location (address)that holds some piece of data, where thevalue of the data cannot change duringexecution of the program.

Page 42: Programs and Data

Declarations

In C#, all variables and constants must be declared before they are used in a program.

C# is what is known as a strongly typed language.This means that we must tell the compiler what thedata type is for every variable. The compiler thenchecks all operations to make sure that they arevalid for the given type of data.

Page 43: Programs and Data

Question . . .

Assume that you are able to peek into the memory of yourcomputer, and you see the bit pattern

0000 0000 0000 0000 0000 0000 0110 0010

What does this bit pattern mean?

Page 44: Programs and Data

The correct answer is that you don’t know.Unless you know what type of data you arelooking at, it is impossible to interpret thebits stored in memory.

Page 45: Programs and Data

Integer Representation

In most modern digital computers, integer numbers are stored internally in binary. The number of bits used tostore an integer in C# is 32 bits.

Example: the integer 5 is0000 0000 0000 0000 0000 0000 0000 0101

This is the sign bit, and when this bit is zero, the number is positive

Page 46: Programs and Data

Floating Point Representation

Numbers that contain decimal points are stored internally in a very different format. The exact

format depends upon the processor used in the computer, but in general it looks like:

sign exponent Mantissa or Coefficient

for example, the number 6,045.03 (0.604503 x 104) would have sign of 0 an exponent of 4 and a

mantissa of .604503

The actual binary representation is beyond thescope of this course.

Page 47: Programs and Data

Computer InstructionsLocations in memory can hold both dataand instructions. A special register, calledthe program counter points in memory to the next instruction to be executed. The computer fetches the next instruction from memory. The program counter moves to the next instruction. The computer thendecodes and executes the instruction it just fetched.

Page 48: Programs and Data

Machine Language

We call the instructions stored in computer memory machine language instructions. They are defined by the chip manufacturer. For example, the machine instruction

0011 0011 0001 1010

might mean something like

take the byte stored in memory location 0024 and put it into the A register.

Page 49: Programs and Data

SummaryIntegers straight binary representation

Real Numbers split into sign, exponent and coefficient

Characters coded bytes – Unicode an ASCII superset

Instructions coded bytes – machine language

Page 50: Programs and Data

Declaring a Variable

int someNumber;char firstLetter;bool theAnswer;

double density = 12.45;int hoursWorked = 14;char key = ‘g’;

this statement reservesspace in computer memoryfor an integer. We can then refer to the data in this location using the name “someNumber” whichis an alias for the the address in memory where the value is stored.

this statement reservesspace in computer memory for a character. The bit patternfor ‘g’ is then stored in thatlocation. We can now refer to thedata in this location using the name “key” .

Page 51: Programs and Data

int idata = 500;

data type(size & shape)

identifier (an alias for its address)

value(value in memory)

Page 52: Programs and Data

Declaring a Variable

int value1, value2, value3;

This statement, termed a comma delimited list, declares threevariables, all of which are int’s with an unknown value .

Page 53: Programs and Data

Declaring a Variable

int value1= 12, value2= 4, value3= 21;

This statement, comma delimited list, declares threevariables, all of which are int’s, and initializes them.

Page 54: Programs and Data

Declaring a Constant

const int SCALE_VALUE = 14;

The keyword const means that this is a constant.You cannot change the value after it is declared and initialized.

We normally use all upper caseletters when writing the name of a constant.

Page 55: Programs and Data

AssignmentThe easiest way to change the value of a variable

is to use an assignment statement.

temperature = 68.4;

note that all statementsend with a semicolon.

the right hand side of the assignmentstatement may be a literal value, oran expression involving variables, literalvalues, and operators, or even methodcalls.

the expression on the rightside of the operator is evaluatedand the resulting value is storedin the storage location allocatedto the variable “temperature”

Page 56: Programs and Data

Assignment Compatibility

In general, it is invalid to assign a variable of one typeto a variable of another. For example if you write

int a = 6.52;

The compiler will issue the warning Cannot implicitly convert type 'double' to 'int'. …

This means you are trying to put a square peg in around hole. It won’t fit. REMEMBER variables havesizes and shapes.

Page 57: Programs and Data

Assignment Compatibility

Note that you can do this assignment.

double a = 6;

The compiler will force a conversion. Why?Sort of like being able to put a round peg in a square hole

Page 58: Programs and Data

The compiler will allow you to do Widening Conversions

double a = 3;

because no information will be lost.

The compiler will not allow you to do Narrowing Conversions

int pi = 3.14159;

because information is lost.

Page 59: Programs and Data

Un-initialized Data

In C#, numbers are not always initialized to a known value. Thus theymay not always be what you expect.

So …… always initialize data when it is declared.

Page 60: Programs and Data

Initializing Data

int numOne = 5, numTwo = 4, numThree = 17;

int numOne = 5;int numTwo = 4;int numThree = 17;

Page 61: Programs and Data

Literal DataIn the statement

sum = a + 5;the value 5 is what is called literal data.

It is good programming practice to use constantsinstead of literal data in your program.

const int MAX = 5;...sum = a + MAX;

Exceptions are 1, -1 and 0

Page 62: Programs and Data

We use the term “Magic Numbers” to refer toliteral data that is written into an expressionin your program.

double avgTemperature = sumTemperature / 2;

This is a magic number

You do not want magic numbers in your programs.They make programs hard to maintain. You willlose points if I see magic numbers in your programs.

Page 63: Programs and Data

Objects and Classes

Object oriented languages give programmers theability to model real-world objects.

Page 64: Programs and Data

for example, a car has attributes* it is black* it has a 200 hp engine* it has 2 doors* it was built in 1943* etc

it also has behaviors* when you turn the key it starts* when you press the brake it stops* when you push the horn it beeps* etc

object-oriented languagesencapsulate the data and themethods that operate on thatdata into an object.

Data

Methods

Page 65: Programs and Data

size

color

GetSi

ze ( )

GetColor( )

an object’s methods (behaviors)manage specific piecesof data (attributes) inside the object.

External Method

methods outside ofthe object cannot see or manipulate the object’sdata, which is private.However, they can call public methods inside the object to accessthe data.

Page 66: Programs and Data

ClassesLater on, we will spend much more time talkingabout objects and classes. For now, just thinkof a class as a blueprint that the computer useswhen creating objects of that class. When we writean object oriented program, much of our time is devoted to designing and writing classes.

Page 67: Programs and Data

Languages that primarily deal with objectsare called object-oriented languages.

Page 68: Programs and Data

Some Convenient ClassesC# has built in to it some classes that will make ourprogramming tasks much easier. The first of these wewill talk about is the String class.

Page 69: Programs and Data

A string is just a sequence of characters.

“hello”“George”

“12 East State Road”

Page 70: Programs and Data

Declare a string this way:

string myName;

Page 71: Programs and Data

Declare a string and give it an initial value this way:

string myName = “John Dolittle”;

Page 72: Programs and Data

Some Convenient ClassesThe other important class we need to talk aboutis the Console class.

Page 73: Programs and Data

keyboard bufferConsole.In program

keyboard buffer

output bufferConsole.Out program

display buffer

When a Console program executes, the C# runtimeenvironment automatically creates these two streamobjects to help manage Console input and output.

Page 74: Programs and Data

Console.ReadLine( )

The Console class provides the ReadLine( ) method to readdata from the standard input stream, Console.In. This methodwaits for the user to type in some data and press the Enter key.The ReadLine( ) method returns the data that the user typed inas a string object.

keyboard bufferConsole.In program

keyboard buffer

Page 75: Programs and Data

String name;name = ReadLine( );

keyboard bufferConsole.In

name

keyboard bufferJohn Doe

John Doe

When using the Console class, be sure to addusing static System.Console;

Page 76: Programs and Data

When dealing with numbers, we have to use theParse method to convert the string value intothe appropriate numerical data type

int age = 0;age = int.Parse(ReadLine( ) );

keyboard buffer

Console.Inage

keyboard buffer25

25Parsemethodthe string “25”

Page 77: Programs and Data

When dealing with numbers, we have to use theParse method to convert the string value intothe appropriate numerical data type

double money = 0.0;money = double.Parse(ReadLine( ) );

keyboard buffer

Console.Inmoney

keyboard buffer12.50

12.50

ParsemethodThe string “12.50”

Page 78: Programs and Data

output bufferConsole.Out program

Console.WriteLine

display buffer

The Console class provides the WriteLine( ) method to writeTo the standard output stream, Console.Out. This methodtakes a string as it’s parameter. After writing to the display,the cursor is moved to the next line.

Page 79: Programs and Data

output bufferConsole.Outname

Console.WriteLine

display buffer

string name = “Joe Coder”;WriteLine( name );

Joe CoderJoe Coder

Page 80: Programs and Data

output bufferConsole.Outmoney

Console.WriteLine

display buffer

Numbers are automatically converted tostrings by the WriteLine( ) method:

double money = 12.50WriteLine( money);

12.5012.50

Page 81: Programs and Data

output bufferConsole.Outmoney

Console.WriteLine

display buffer

You can combine string literals and numerical datausing the placeholder { .. } to mark the place wherethe numerical data should be displayed.

double money = 12.50WriteLine($ “You owe {money} to me.”);

12.50You owe 12.50 to me

Page 82: Programs and Data

output bufferConsole.Outmoney

Console.WriteLine

display buffer

You can use a format string to format the output

double money = 12.50WriteLine($ “You owe {money:C} to me.”);

12.50You owe $12.50 to me

Page 83: Programs and Data

Formatting Specifiers

D or d: Display an integer value as a decimal numberF or f: Display a real value - default is two digits after the decimal pointC or c: Display a real value as currency

Page 84: Programs and Data

Formatting Strings

With an integer you can use a number to indicate how many digits to display

int number = 23;WriteLine($“The value is {number:D4}” );

The value is 0023

Page 85: Programs and Data

Formatting Strings

With a double you can use a number to indicate how many decimal digits to display

double number = 23.98344;WriteLine($“The value is {number:F3}“);

The value is 23.983

Page 86: Programs and Data

Formatting Strings

You can arrange things on the screen by using numbersto specify a field width and justify the output in the field.

double number = 23.98344;Console.WriteLine($“The value is {number, 6:F2}” );

The value is _23.98

2 3 . 9 8

6 character field

Page 87: Programs and Data

Data displayed on a Graphical User Interfacemust first be converted to a string.

That string is then assigned to the Text Property of the control where you want to see it.

Page 88: Programs and Data

Suppose the name of this TextBox control is “outputTxtBox”

and we have an integer named sum to show there.

outputTxtBox.Text = $”{sum:f2}”;

Page 89: Programs and Data

Style

When writing programs, in any programminglanguage, it is helpful to use a consistentstyle. Good software development organizationswill often dictate that programmers use a specificstyle. This makes it easier for everyone to readthe code that is being developed.

Program that do not conform to the style guidelinesfor this class will lose points.

Page 90: Programs and Data

Style - IdentifiersUse names that have meaning. Avoid single character, very short, or very long names.

Examples: Meaningful Names Baffling Names amount aisFinished xl

ConstantsAll upper case with words separated by an underscore

Example: SIZE Classes and Method namesTitle case (capitalization of the first letter in each word)

Example: SimpleCalc( ) Data

VariablesLower case for the first word and title case for every word thereafter.

Example: myAccount

Page 91: Programs and Data

Style - BracesMany C# language statements do not require braces; however, some statementssuch as conditionals and loops may or may not require braces and it is good programming practice to provide them. Use braces liberally to visually delimit the beginning and end of code blocks. Including braces now avoids the possibility of errors creeping into your code when you add additional statements at the last minute.

Place the opening (left) brace { so that it lines up with the left side of class headers, function headers, conditional statements, or repetitive statements. Place the closing (right) brace } in the same column as the opening brace. Always enter braces in opening/closing pairs to avoid forgetting to add one or the other or both. For braces that span more than three to five lines, comment the ending brace to indicate its nature (e.g., // end if ).

Page 92: Programs and Data

Indentation

As you moved from block to block, indentat least three spaces. Indentation makes codemuch more readable.

Page 93: Programs and Data

Examplevoid reviewCode( ){ if ( meetsGuidelines ) { Console.WriteLine(““Proceed to the next assignment”); } else { Console.WriteLine(“Rework your documentation”); } // end if/else} // end reviewCode( )

Page 94: Programs and Data

Your Own Code DeclarationEvery source code file must contain the followingdeclaration. Code that does not contain thisdeclaration will not be graded!

"I declare that the following source code was written solely by me. I understand that copying any source code, in whole or in part, constitutes cheating, and that I will receive a zero on this project if I am found in violation of this policy.

Page 95: Programs and Data

Magic NumbersA magic number is any numeric literal other than 1, 0, or –1 used in your program. However if 1, 0 and –1 are used to represent something other than the integers 1, 0, or –1 they will be considered magic numbers. Unfortunately, most code you will see in C# books or programming books in general will include magic numbers because it’s easier to code in the short run. In the long run, six months from today, you will be clueless as to what the number means. Therefore, DON’T USE MAGIC NUMBERS in your assignments.

Page 96: Programs and Data

CommentsKeep in mind that every program that you submit shouldcontain comments that describe how the program works.

More on this later …

Page 97: Programs and Data

Where are variables stored?

If a variable is declared inside of the curly brackets,that define a method, then that variable is said to be local to the method. Only the code in the method cansee a local variable. It is stored on the stack.If a variable is declared outside of the curly brackets,that define a method, then that variable is said to be aclass level variable. It is stored in the data segment. It is available to any method in the program.

Page 98: Programs and Data

using System;

Class Program{ const double PI = 3.14149;

static void Main( ) { double radius;

. . . }}

Declared inside ofcurly braces – stack

This is a local variable

Page 99: Programs and Data

using System;

Class Program{ const double PI = 3.14149;

static void Main( ) { double radius;

. . . }}

Declared outside ofany method – data segment

It is a global variable.It is available to any methodin the class Program.

This is a class level variable

Page 100: Programs and Data

Practice

Name the simple C# data types.

Page 101: Programs and Data

PracticeHere is some data stored in the memory of thecomputer.

0000 0000 0000 1001

What is it’s value?

Page 102: Programs and Data

PracticeSuppose that you needed a Student objectin a course registration program.

What attributes might a Student have?

What behaviors might a Student require?

Page 103: Programs and Data

Practice

In which part of computer storage iseach of the following stored?

* A class level variable * A local variable

Page 104: Programs and Data

Practice

Name one class that we have learned about in thislesson.

Page 105: Programs and Data

PracticeWhich method is used to convert data into itscharacter representation and send it to thestandard output device?

To what class does this method belong?

Page 106: Programs and Data

Practice

Name a method that is used to convert numerical data from its character representation and store it to in memory in its binary representation.

Page 107: Programs and Data

Practice

Write a program that prints the message

“Hello, my name is Hal”.

Then the program will prompt the user for his or her first name. It then Will print

“Hello, user name, how are you?”

Page 108: Programs and Data

PracticeWrite a program that prints the message

“Hello, my name is Hal”.

Then the program will ask the user for his or her name.Get the name and save it in a String object.

Then print the message

“Hello, user name, how are you?”

Prompt the user to type in their age. Save it in anInteger. Then print the message

“user name, you are n years old”

Page 109: Programs and Data

PracticeWrite a program that does the following:• Declares an integer, a double, and a character.• In turn, asks the user to enter in an appropriate piece of

data for each variable and stores it in that variable.• Add together the integer and the double and the character. The result is stored in a double named sum.• Print out the sum.• Ask the user to type their name (first and last).• Store their name in a string variable.• Print out “Thank you (their name).

• Be able to discuss the results of your program.