Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This code must be written in c# NOTE: Modulo division (quotient and remainder division) is notcovered in the textbook but it is an important aspect

This code must be written in c#

NOTE: Modulo division (quotient and remainder division) is notcovered in the textbook but it is an important aspect of anyprogramming language. I describe below the basics of how itworks.
Segment of C# code
….
int myQuotient = 0, myRemainder = 0;
myQuotientInt = 100 / 3; //this will return avalue of 33 for the quotient
myRemainderInt = 100 % 3; //this will return avalue of 1 for the remainder
….
The result of the above is the Quotient is 33 and the Remainder is1,
meaning that the answer to 100 divided by 3 can be stated as “33Remainder 1”

1. (50 Points) Decimal (Real Number) Division vs. Modulo(Quotient-Remainder) Division in C# Create a C# windows formthat demonstrates the differences between division operations usingdecimal division vs. modulo division. Use the enclosed .exeas an example and create a program that looks and functions thesame. Be sure to refer to the general programming guidelineslisted above. Name your project:
DivisionDecVsMod - Your Name
Decimal division results in a real number (eg. 100.0 divided by 3.0= 33.333333). Modulo division results in a quotient, remainder (eg.100 divided by 3 = Quotient:33 Remainder:1. Computerprogramming languages typically provide the ability to perform bothtypes of division. This Form will show the result of dividing onenumber by another as a 1) Quotient/Remainder result and as a 2)Real number/decimal result.
a) Setup two text boxes to hold the two numbers to be divided (theDividend by the Divisor)
b) Add a ‘Calculate’ Button
c) Upon clicking the button, validate the two text boxes usingint.TryParse… to verify that a number was entered into each textbox (the need for validation should be becoming ‘second nature’ toeach of you!); ALSO since dividing by zero causes abends incomputer programs, validate that the Divisor is not equal tozero.
d) Also calculate the result of the division using decimal division(think: use the / operator ) and display in decimal format with 4decimals (eg. 33.3333) in one label on the form; you may also needto explicitly cast the integers as decimal via code likemyResultDecimal = (decimal)myInt1 / (decimal)myInt2;
e) Also calculate the result of the division using modulo division[think: this is a combination of two statements, one using the /division operator, and the other using the % division-remainderoperator) and display 1) the resulting Quotient value in a label onthe Form and also 2) the resulting Remainder value in differentlabel on the form (eg. Quotient:33 Remainder:1 ]
f) Include a Clear All button that clears all the textboxes andlabels



(see next page)

CISS 160 Homework – Loops, Listboxes, Division via Mod
Page 3 of 3

2. (80 Points) Looping and ListBoxes. The C# languageprovides various aspects of the language to handle ‘looping’through a defined set of C# statements within braces {…} over andover until some end point is reached. Also, there is aListBox control that can be added to any Form allowing for multiple‘items’ (or lines) of text to be displayed in one ListBox controlon a Form. Use the enclosed .exe as an example and create a programthat looks and functions the same. Be sure to refer to thegeneral programming guidelines listed above. Name yourproject:
LoopListBoxMod - Your Name
This Form will allow the User to type in a Starting Year and anEnding Year value. Also the User can check a Checkbox toindicate if they want to know of any year in which a PresidentialElection will occur, and a Checkbox to indicate if they want toknow of any year in which a Federal Census will occur. Whenthe ‘Loop Through the Years’ button is clicked, your program shouldloop, starting with the Start Year value and going to the End Yearvalue, and display each Year that is looped through in the listbox,along with text describing if that a given year is a PresidentialElection year and/or a Census year, if applicable.
a) Setup two text boxes to hold the Starting Year and Ending Year;setup two Checkboxes for the user to indicate if they want to knowif a given year is 1) a Presidential Election year and/or 2) aCensus year
b) Add a ‘Loop Through the Years’ Button
c) Upon clicking the button, validate the two text boxes usingint.TryParse… to verify that a number was entered into each textbox (the need for validation should be becoming ‘second nature’ toeach of you!)
d) Loop through all years starting with the Starting Year andending with the Ending Year using any C# looping structure [think:use a for (…) OR use a while(…) looping structure]
e) As each year is processed in the loop, display a line (add anItem) to the ListBox control showing:
1) The current Year being processed, along with
2) If the Presidential Election Checkbox is checked, and if theYear being processed is a Presidential Election Year (think: evenlydivisible by 4… think Remainder % operator) then also display “, isan Election Year”, then
3) If the Census Year Checkbox is checked, and it the Year beingprocessed is a Census Year (think: evenly divisible by 10… thinkRemainder % operator) then also display “, is a CensusYear”
4) For Example: “Year 2000, is an Election Year, is a CensusYear”
e) NOTE: the determination of the Election and/or Census status ofa given Year requires NO HARD CODING of any specific year numbersin your if() statements. These determinations should behandled using modulo division (think: remainder division using the% operator)
– DO NOT HAVE ‘LONG’ if() CONDITIONS LIKE THIS IN YOUR CODE:if (currentYear == 2000 || currentYear == 2010 || currentYear =2020 etc etc) – think: ‘how can I use a Remaindercalculation/variable to figure out the Election Year, CensusYear?’
f) Include a Clear All button that clears all the textboxes andlabels and/or listboxes


Take all of your completed project folders above and copy them into a folder named:
DivLoopList - Your Name
Zip up this folder and submit the zip file in this dropbox by thedue date and time.

Step by Step Solution

3.36 Rating (165 Votes )

There are 3 Steps involved in it

Step: 1

I understand your request and I can help you create a simple C Windows Forms application for the pro... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals of Cost Accounting

Authors: William Lanen, Shannon Anderson, Michael Maher

3rd Edition

9780078025525, 9780077517359, 77517350, 978-0077398194

More Books

Students also viewed these Programming questions

Question

Find the lengths of the curves. The cardioid r = 1 + cos

Answered: 1 week ago

Question

Your answer is partially correct

Answered: 1 week ago

Question

Do transfer prices exist in centralized firms? Why?

Answered: 1 week ago

Question

Evaluate the answers accurate to the cent. 3(6 + 4)2 - 5(17 - 20)2

Answered: 1 week ago

Question

Evaluate the answers accurate to the cent. 5[19 + (52 - 16)2]2

Answered: 1 week ago

Question

Evaluate the answers accurate to the cent.

Answered: 1 week ago