ITAP1001 Practical Exercise 3

pdf

School

Davenport University *

*We aren’t endorsed by this school

Course

MISC

Subject

English

Date

Nov 24, 2024

Type

pdf

Pages

4

Uploaded by AdmiralFreedom582

Report
ITAP1001 Software Development Fundamentals Practical Exercise 3 September 2023
ITAP1001 Practical Exercise 3 Copyright © 2023 VIT, All Rights Reserved 2 Task 1: ReadLine and WriteLine 1. practical example representing console input and formatted text in the form of a letter: class PrintingLetter { static void Main() { Console .Write( "Enter person name: " ); string person = Console .ReadLine(); Console .Write( "Enter book name: " ); string book = Console .ReadLine(); string from = "Authors Team" ; Console .WriteLine( " Dear {0}," , person); Console .Write( "We are pleased to inform " + "you that \"{1}\" is the best Bulgarian book. {2}" + "The authors of the book wish you good luck {0}!{2}", person, book, Environment .NewLine); Console .WriteLine( " Yours," ); Console .WriteLine( " {0}" , from); } } 2. The result of the execution of the above program could be the following: Enter person name: Readers Enter book name: Introduction to programming with C# Dear Readers, We are pleased to inform you that "Introduction to programming with C#" is the best Bulgarian book. The authors of the book wish you good luck Readers! Yours, Authors Team 3. In this example we have a letter template. The program "asks" a few questions to the user and reads from the console information needed to print the letter by replacing the formatting specifiers with the data filled in by the user.
ITAP1001 Practical Exercise 3 Copyright © 2023 VIT, All Rights Reserved 3 Task 2: Expression and operators 1. Calculating an area of a rectangle or a triangle. class CalculatingArea { static void Main() { Console .WriteLine( "This program calculates " + "the area of a rectangle or a triangle" ); Console .WriteLine( "Enter a and b (for rectangle) " + "or a and h (for triangle): "); int a = int .Parse( Console .ReadLine()); int b = int .Parse( Console .ReadLine()); Console .WriteLine( "Enter 1 for a rectangle or " + "2 for a triangle: " ); int choice = int .Parse( Console .ReadLine()); double area = ( double ) (a * b) / choice; Console .WriteLine( "The area of your figure is " + area); } } 2. The result of the execution of the above program could be the following: This program calculates the area of a rectangle or a triangle Enter a and b (for rectangle) or a and h (for triangle): 5 4 Enter 1 for a rectangle or 2 for a triangle: 2 The area of your figure is 10
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
ITAP1001 Practical Exercise 3 Copyright © 2023 VIT, All Rights Reserved 4 Exercise 3.1 Write a program that reads from the console the radius "r" of a circle and prints its perimeter and area. 3.2 Write a program to calculate (a+b) 2 .