תרגיל #3 פתרונות. חלק א ' ה STRUCT Structure COURSES Dim semkors, semmarza As String Dim kodkors, mispartalmidim, zionminimali As Integer End Structure.

Slides:



Advertisements
Similar presentations
Modeling using VBA. Covered materials -Userforms -Controls -Module -Procedures & Functions -Variables -Scope.
Advertisements

If – Case Programs CSC Arwa © 2008.
תרגילים. גדול, קטן, וממוצע מקובץ Imports System.IO Module Module1 Sub Main() Dim readnum As StreamReader readnum = _ My.Computer.FileSystem.OpenTextFileReader.
פתרון תרגיל 10. שאלה #1 Module Module1 Sub Main() Dim maarach(9), zoogy(4), ezoogy(5) As Integer Dim i, counter, j As Integer For i = 0 To 9 Console.WriteLine("please.
פתרון בוחן הכיתה. שאלה #1 Module Module1 Sub Main() Dim x, z As Integer x = Console.ReadLine() z = Console.ReadLine() If (x = 0) Then Console.WriteLine("Error")
פתרון תרגיל 11. שאלה #1 Module Module1 Sub Main() Dim x(10, 10) As Integer Dim i, j As Integer For i = 1 To 10 For j = 1 To 10 x(i, j) = i * j Console.Write("
מערכים מבוא לתכנות למנע"ס - שבוע מספר 8 - מאיר קומר - סמסטר ב' - תשס"ו והנה בעיה כתוב תוכנית אשר תקלוט 36 מספרים ותדפיס כמה מתוכם גדולים יותר מהממוצע.
Chapter 61 Flags A flag is a variable that keeps track of whether a certain situation has occurred. The data type most suited to flags is Boolean.
פתרון תרגילים #9. דוגמה פשוטה #1 Module Module1 Sub Main() Dim x As String x = Console.ReadLine For i = 1 To x.Length() - 1 Step 2 Console.WriteLine(x(i))
Data Types and Operations Programming Fundamentals (Writing Code)Programming Fundamentals (Writing Code)
מערכים דו ממדי ו STRUCTS פונקציות בוליאנית Module Module1 Function Flip(ByVal word1 As String) As Boolean Dim i As Integer For i = 0 To word1.Length()
CSI 101 Spring 2009 Review and Recap of Visual Basic Wednesday, April 29 th.
الحلقات for For i =1 To x step -2 …………. Next DO while (شرط) …………. Loop DO …………. Loop while (شرط) الحلقة Do while.
VBA & Excel Barry L. Nelson IEMS 465 Fall Quarter 2003.
Class 3 Programming in Visual Basic. Class Objectives Learn about input/output Learn about strings Learn about subroutines Learn about arrays Learn about.
Microsoft Access Using Visual Basic Routines. Visual Basic Datatypes Boolean Byte Currency Date Double Integer Long Object Single String Variant Hyperlink.
 2002 Prentice Hall. All rights reserved. 1 Chapter 5 – Control Structures: Part 2 Outline 5.1Introduction 5.2 Essentials of Counter-Controlled Repetition.
Loops Repeating Code Multiple Times SoftUni Team Technical Trainers Software University
VB Core II Conditional statements Exception handling Loops Arrays Debugging.
OUTPUT: Guess a number (1-100) 60 Too High! Guess a number (1-100) 41 Too Low! Guess a number (1-100) 42 Correct!
Visual Basic CODE. Basics of Code Declaration Declaration Set aside a named place to put things Set aside a named place to put things Assignment Assignment.
 2002 Prentice Hall. All rights reserved. 1 Chapter 4: Control Structures: Part 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures.
© 1999, by Que Education and Training, Appendix A, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.
26/10/ Selection Nested If structures & Complex Multiple Conditions.
Type Conversions Implicit Conversion Explicit Conversion.
MS Visual Basic Applications Walter Milner. Event-driven programming Standard approach for GUIs Contrast with old character interfaces – program determines.
Variables,Constants and Data types Variables temporarily stores values during the execution of an application Variables have a name and data type Declare.
Two Forms Please use speaker notes for additional information!
Lab 6 (2) Arrays ► Lab 5 (1) Exercise Review ► Array Concept ► Why Arrays? ► Array Declaration ► An Example of Array ► Exercise.
CIS 3301 C# Lesson 3 Control Statements - Selection.
Repetition. Loops Allows the same set of instructions to be used over and over again Starts with the keyword loop and ends with end loop. This will create.
Dr. Tami Meredith Saint Mary's & Dalhousie Universities.
Pay Example (PFirst98) Please use speaker notes for additional information!
A: A: double “4” A: “34” 4.
For…Next and Do...While Loops! Happy St. Patrick’s Day!
1 Microsoft® Visual Basic®.NET Language # 2. 2 Flow-Control Statements If … End If Select Case … End Select For… Next Do … Loop Exit.
5.1 Introduction Problem Solving –Requires understanding of: Building blocks Program-construction principles BZUPAGES.COM.
05/02/ Records. 205/02/2016 Learning Objectives State: The difference between records and arrays. The difference between records and arrays. How.
DATA TYPES, VARIABLES AND CONSTANTS. LEARNING OBJECTIVES  Be able to identify and explain the difference between data and information  Be able to identify,
מבנה נתונים ואלגוריתמים ) לשעבר - עיבוד מידע( ד"ר אבי רוזנפלד ד"ר אריאלה ריכרדסון.
 2002 Prentice Hall. All rights reserved. 1 Chapter 5 – Control Structures: Part 2 Outline 5.1Introduction 5.2 Essentials of Counter-Controlled Repetition.
A club in Leicester holds exclusive after party sessions for members only. In order to get into one of the after parties you need to be “on the list”.
Chapter 6 Controlling Program Flow with Looping Structures.
26/06/ Iteration Loops For … To … Next. 226/06/2016 Learning Objectives Define a program loop. State when a loop will end. State when the For.
Programming Right from the Start with Visual Basic .NET 1/e
VBA - Excel VBA is Visual Basic for Applications
Repeating Code Multiple Times
Agenda Warmup Finish 2.4 Assignments
VB.Net Programming Console Application
Method.
Chapter 5 – Control Structures: Part 2
Introducing Do While & Do Until Loops & Repetition Statements
Chapter 5 Structures.
CSCI 3327 Visual Basic Chapter 7: Data Manipulation in Arrays
Review Operation Bingo
مراجعة الحاسب.
حلقات التكرار.
البرمجة بلغة فيجول بيسك ستوديو
Chapter (3) - Looping Questions.
VB.Net Programming Console Application
VB.Net Programming Console Application
Do … Loop Until (condition is true)
Chapter 7: Using Functions, Subs, and Modules
LabVIEW.
Text / Serial / Sequential Files
3.1 Iteration Loops For … To … Next 18/01/2019.
Procedures: Functions and Subroutines
Dictionary Builder Part 4 Loading Files.
VB.Net Programming Console Application
C# Revision Cards Data types
Presentation transcript:

תרגיל #3 פתרונות

חלק א ' ה STRUCT Structure COURSES Dim semkors, semmarza As String Dim kodkors, mispartalmidim, zionminimali As Integer End Structure

פתרון #1 Sub Main() Dim kors() As COURSES Dim endofdata As Boolean Dim ans As String Dim i As Decimal i = -1 Do Until endofdata i += 1 ReDim Preserve kors(i) Console.WriteLine("insert name courses") kors(i).semkors = Console.ReadLine() Console.WriteLine("insert marze name") kors(i).semmarza = Console.ReadLine() Console.WriteLine("insert courses kod") kors(i).kodkors = Console.ReadLine() Console.WriteLine("insert number of student") kors(i).mispartalmidim = Console.ReadLine() Console.WriteLine("insert zion minimali") kors(i).zionminimali = Console.ReadLine() Console.WriteLine("do yo finish? y/n ") ans = Console.ReadLine() If ans.ToUpper = "Y" Then endofdata = True End If Loop End Sub End Module

פתרון #2 Sub Main() Dim Course() As COURSES Dim TF As String = "" Dim I As Integer I = -1 Do While TF = "" I += 1 ReDim Preserve Course(I) Console.Write("Enter Course Name: ") Course(I).Name = Console.ReadLine() Console.Write("Enter Course Code: ") Course(I).Cod = Console.ReadLine() Console.Write("Lecturer Name: ") Course(I).Lecturer = Console.ReadLine() Console.Write("Number of students: ") Course(I).NumberOfStudents = Console.ReadLine() Console.Write("Passing grade: ") Course(I).MinGrade = Console.ReadLine() Console.WriteLine(vbTab) Console.Write("Continue - Press ENTER, End - Press ANY KEY : ") TF = Console.ReadLine() Loop Console.WriteLine("Number of courses: {0}", Size(Course)) Console.WriteLine("Course with most students: {0}", BiggestCourse(Course)) End Sub

ועכשיו הפונקציות : Function Size(ByVal x() As COURSES) As Integer Return x.Length() End Function Function BiggestCourse(ByVal x() As COURSES) As String Dim i As Integer Dim Max As Integer = x(0).NumberOfStudents Dim Pointer As Integer = 0 For i = 1 To x.Length - 1 If x(i).NumberOfStudents > Max Then Max = x(i).NumberOfStudents Pointer = i End If Next Return x(Pointer).Name End Function