Conditional Statements |
|
if |
with Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Text_IO; procedure Exercise is Item : Integer; begin Put_Line("Enter the type of house you want to purchase"); Put_Line("1. Single Family"); Put_Line("2. Townhouse"); Put_Line("3. Condominium"); Put_Line("You Choice? "); Ada.Integer_Text_IO.Get(Item); if Item = 1 then Put_Line("House Type: Single Family"); end if; end Exercise; |
Here is an example of running the program: Enter the type of house you want to purchase 1. Single Family 2. Townhouse 3. Condominium You Choice? 1 House Type: Single Family Here is another example of running the program: Enter the type of house you want to purchase 1. Single Family 2. Townhouse 3. Condominium You Choice? 4 |
with Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Text_IO; procedure Exercise is Item : Integer; begin Put_Line("Enter the type of house you want to purchase"); Put_Line("1. Single Family"); Put_Line("2. Townhouse"); Put_Line("3. Condominium"); Put_Line("You Choice? "); Ada.Integer_Text_IO.Get(Item); if Item = 1 then Put_Line("House Type: Single Family"); else Put_Line("Another type of property"); end if; end Exercise; Here is an example of running the program: 1. Single Family 2. Townhouse 3. Condominium You Choice? 1 House Type: Single Family Here is another example of running the program: Enter the type of house you want to purchase 1. Single Family 2. Townhouse 3. Condominium You Choice? 25 Another type of property with Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Text_IO; procedure Exercise is Item : Integer; begin Put_Line("Enter the type of house you want to purchase"); Put_Line("1. Single Family"); Put_Line("2. Townhouse"); Put_Line("3. Condominium"); Put_Line("You Choice? "); Ada.Integer_Text_IO.Get(Item); if Item = 1 then Put_Line("House Type: Single Family"); elsif Item = 2 then Put_Line("House Type: Townhouse"); elsif Item = 3 then Put_Line("House Type: Condominium"); else Put_Line("House Type: Unknown"); end if; end Exercise; Here is an example of running the program: Enter the type of house you want to purchase 1. Single Family 2. Townhouse 3. Condominium You Choice? 3 House Type: Condominium Here is another example of running the program: Enter the type of house you want to purchase 1. Single Family 2. Townhouse 3. Condominium You Choice? 244 House Type: Unknown with Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Text_IO; procedure Exercise is type HouseTypes is (SingleFamily, Townhouse, Condominium); -- , Unknown); HouseCategory : HouseTypes; begin HouseCategory := Townhouse; case HouseCategory is when SingleFamily => Put_Line("House Type: Single Family"); when Townhouse => Put_Line("House Type: Townhouse"); when Condominium => Put_Line("House Type: Condominium"); end case; end Exercise; Here is an example of running the program: House Type: Townhouse with Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Text_IO; procedure Exercise is Choice : Integer; begin Put_Line("Enter the type of house you want to purchase"); Put_Line("1. Single Family"); Put_Line("2. Townhouse"); Put_Line("3. Condominium"); Put_Line("You Choice? "); Ada.Integer_Text_IO.Get(Choice); case Choice is when 1 => Put_Line("House Type: Single Family"); when 2 => Put_Line("House Type: Townhouse"); when 3 => Put_Line("House Type: Condominium"); when others => Put_Line("House Type: Unknown"); end case; end Exercise; Here is an example of running the program: Enter the type of house you want to purchase 1. Single Family 2. Townhouse 3. Condominium You Choice? 2 House Type: Townhouse Here is another example of running the program: Enter the type of house you want to purchase 1. Single Family 2. Townhouse 3. Condominium You Choice? 14 House Type: Unknown |
with Ada.Text_IO; use Ada.Text_IO; procedure Welcome is a : Integer := 0; begin while a /= 4 loop Put_Line("Welcome to Ada Programming"); a := a + 1; end loop; end Welcome; with Ada.Text_IO; use Ada.Text_IO; procedure Exercise is begin for Counter in 1 .. 5 loop Put_Line("Number " & Integer'Image(Counter)); end loop; end Exercise; Here is an example of running the program: Number 1 Number 2 Number 3 Number 4 Number 5 |
|
|||||
|
|
||
Previous | Copyright © 2010-2016, FunctionX | Next |
|