{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "af44ef78",
   "metadata": {},
   "source": [
    "# Chapter Review\n",
    "\n",
    "1. Which of these expressions are legal in C#?\n",
    "   Think of the results.\n",
    "   Explain.\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9f5c12d6",
   "metadata": {
    "language_info": {
     "name": "polyglot-notebook"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [],
   "source": [
    "   \"a\" + \"b\"\n",
    "   \"a\" + 'b'\n",
    "   \"a\" + 2\n",
    "   2 + \"a\"\n",
    "   \"a\" + 2 * 3;\n",
    "   \"a\" + 2 + 3\n",
    "   2 + 3 + \"a\"\n",
    "   2 + 3 * \"a\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "36ebeceb",
   "metadata": {},
   "source": [
    "\n",
    "   Think first; try in csharprepl; reconsider if necessary.\n",
    "\n",
    "2. Write a single `WriteLine` statement that would produce output\n",
    "   on two separate lines, not one.\n",
    "\n",
    "3. What is printed?\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "71cc42b2",
   "metadata": {
    "language_info": {
     "name": "polyglot-notebook"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [],
   "source": [
    "   Console.WriteLine(\"{1} {0} {2} {1} {0}\", 'B', 2, \"or not\");\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "32f9a326",
   "metadata": {},
   "source": [
    "\n",
    "4. Which of these casts is necessary, and which could be left out\n",
    "   (and be legal and mean the same thing)? Before testing,\n",
    "   think what the values of the variables will be\n",
    "   for the first two or three:\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "905e1b5c",
   "metadata": {
    "language_info": {
     "name": "polyglot-notebook"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [],
   "source": [
    "   int x= (int)5.8;\n",
    "   double y = (double)6;\n",
    "   char c = (char)('a' + 1)\n",
    "   int z = (int)'a' + 1;\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aa09dac7",
   "metadata": {},
   "source": [
    "\n",
    "5. Write a program file, call it add3.cs, that prompts\n",
    "   the user for\n",
    "   three numbers, *not necessarily integers*, and lists all three,\n",
    "   and their sum, in similar format to:\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "be73ac11",
   "metadata": {
    "language_info": {
     "name": "polyglot-notebook"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [],
   "source": [
    "   using System;\n",
    "\n",
    "   class GoodSum\n",
    "   {\n",
    "       static void Main()\n",
    "       {\n",
    "           Console.Write ( \"Enter an integer: \");\n",
    "           string xString = Console.ReadLine();\n",
    "           int x = int.Parse(xString);\n",
    "           Console.Write( \"Enter another integer: \");\n",
    "           string yString = Console.ReadLine();\n",
    "           int y = int.Parse(yString);\n",
    "           int sum = x + y;\n",
    "           Console.WriteLine(\"They add up to \" + sum);\n",
    "       }\n",
    "   }\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6fba144a",
   "metadata": {},
   "source": [
    "\n",
    "6. Write a program that prompts the user for\n",
    "   two integers, and then prints them out in a sentence with\n",
    "   an integer division problem like:\n",
    "\n",
    "   ```\n",
    "   The quotient of 14 and 3 is 4 with a remainder of 2.\n",
    "   ```\n",
    "\n",
    "   Review remainders if you forget the integer division or remainder operator."
   ]
  }
 ],
 "metadata": {
  "jupytext": {
   "cell_metadata_filter": "-all",
   "main_language": "python",
   "notebook_metadata_filter": "-all"
  },
  "kernelspec": {
   "display_name": ".NET (C#)",
   "language": "C#",
   "name": ".net-csharp"
  },
  "language_info": {
   "name": "csharp"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
