VBA Problems_Feb 2013.pdf

26
1 Copyright © Ivy Professional School - 2009-10 (All Rights Reserved) Ivy Professional School VBA Programming Questions

Transcript of VBA Problems_Feb 2013.pdf

Page 1: VBA Problems_Feb 2013.pdf

1

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Ivy Professional School

VBA Programming Questions

Page 2: VBA Problems_Feb 2013.pdf

2

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 1#

• Enter a number through the keyboard. Write a program to Evaluate and display if the number is Even or Odd.

Page 3: VBA Problems_Feb 2013.pdf

3

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 2#

• Enter a Mobile Number through Keyboard and give the name of the service provider based on the first 3 digits of mobile number.

• AIRTEL - 990 • BSNL – 901 • MTS – 902 • Vodafone – 900 • Others – Rest of number

Page 4: VBA Problems_Feb 2013.pdf

4

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 3#

• Enter the marks of a student and display the grade based on the marks.

• >=90 : A • 80 to 89 : B • 70 to 79 : C • 60 to 69 : D • <60 : Fail

Page 5: VBA Problems_Feb 2013.pdf

5

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 4#

• If a five digit number is entered through the keyboard, write a program to calculate the sum of digits.

Page 6: VBA Problems_Feb 2013.pdf

6

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 5#

• Write a program to reverse any three digit number and after that check whether they are equal or not.

Page 7: VBA Problems_Feb 2013.pdf

7

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 6#

• If three sides of a triangle are entered through the keyboard. Write a program to check whether the triangle is isosceles , equilateral or scalene triangle.

• HINTS: If s1, s2,s3 are three sides of a triangle then – SCALENE S1<>S2<>S3 – ISOSCELES S1=S2, S2<>S3 – EQUILATERAL S1=S3=S2

Page 8: VBA Problems_Feb 2013.pdf

8

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 7#

• Write a program that asks the user to enter a number and determines whether it is divisible by 5 and 6, it is divisible by 5 or 6, and whether it is divisible by 5 or 6 but not both.

• E.g.: If input is 10, then output should be: – Is 10 divisible by 5 and 6? False – Is 10 divisible by 5 or 6? True – Is 10 divisible by 5 or 6 but not both? True

Page 9: VBA Problems_Feb 2013.pdf

9

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 8#

• The wind chill index (WCI) is calculated from the wind speed v in miles per hour and the temperature t in Fahrenheit. Three formulas are used, depending on the wind speed: – if (0 <= v <= 4) then WCI = t – if (v >=45) then WCI = 1.6t - 55 – otherwise, WCI = 91.4 + (91.4 - t)(0.0203v -

0.304(v)1/2 - 0.474). • Write a program that can calculate the wind chill

index.

Page 10: VBA Problems_Feb 2013.pdf

10

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 9#

• Find the numbers between 1 to 500 which follow Armstrong rule below.

• HINTS: for example 153 coz. 1*1*1+5*5*5+3*3*3= 153

Page 11: VBA Problems_Feb 2013.pdf

11

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 10#

• Show all the possible combinations of any unique 3 numbers

• HINTS: for example a 3 digit number has a total combinations of 3C1 * 3C1 *3C1 = 3*3*3= 27 – 111, 122, 123, 312, 112 etc..

Page 12: VBA Problems_Feb 2013.pdf

12

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 11#

• Write a program to develop 10 elements of fibonacci series and show it in one message box.

Page 13: VBA Problems_Feb 2013.pdf

13

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 12#

• Write a program to develop ‘n’ elements of fibonacci series and show it in one message box.

Page 14: VBA Problems_Feb 2013.pdf

14

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 13#

• Calculate the factorial of any given number. • HINTS: Factorial of 5= 5*4*3*2*! Factorial of 6= 6*5*4*3*2*1

Page 15: VBA Problems_Feb 2013.pdf

15

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 14#

• In a gymnastics or diving competition, each contestant’s score is calculated by dropping the lowest and highest scores and then adding the remaining scores. Write a program that allows the user to enter eight judges’ scores and then outputs the point received by the contestant. A judge awards point between 1 and 10, with 1 being the lowest and 10 being the highest.

• For example, if the scores are: 9.2, 9.3, 9.0, 9.9, 9.5, 9.5, 9.6 and 9.8, then the contestant receives a total of 56.9 points.

Page 16: VBA Problems_Feb 2013.pdf

16

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 15#

• Write a program that can read three integers from the user and then determines the smallest value among the three integers.

Page 17: VBA Problems_Feb 2013.pdf

17

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 16#

• Write a program that asks the user to enter any number of integers that are in the range of 0 to 30 inclusive and count how many occurrences of each number are entered. Use a suitable sentinel to signal the end of input. Show the numbers (with the number of occurrences) that were entered one or more times.

Page 18: VBA Problems_Feb 2013.pdf

18

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 17#

• Write a program to enter a word and calculate the number of vowels and consonants.

• e.g. Word is ‘Professional’ – Vowel = 5, consonants=7

Page 19: VBA Problems_Feb 2013.pdf

19

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 18#

• Write a program such that you ask the user if a new worksheet should be added to the active workbook.

• If a new worksheet is added to the workbook then change the name of the new worksheet to a user given name.

Page 20: VBA Problems_Feb 2013.pdf

20

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 19#

• Write a program such that you add two worksheets after second sheet.

• Also, rename all the worksheets by appending your initials after the basic name.

• Eg. Sheet1 will become Sheet1_EA Sheet2 will become Sheet2_EA…

Page 21: VBA Problems_Feb 2013.pdf

21

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 20#

• Create a User Defined Function which gives the Day based on the date given.

• EXAMPLE: 3/24/2012 - Saturday

Page 22: VBA Problems_Feb 2013.pdf

22

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 21#

1. Create a User Defined Function to calculate the area of a triangle using the Heron’s Formula-

e.g. Three sides of triangle – a,b,c s=(a+b+c)/2 Area of Triangle = Square root of (s(s-a)(s-b)(s-c)) 2. Through programming input three sides of a triangle and

check whether it is feasible triangle or not. If the triangle is feasible calculate the area using the user defined function.

Page 23: VBA Problems_Feb 2013.pdf

23

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 22#

• Write a program to highlight duplicate record in an excel sheet.

Page 24: VBA Problems_Feb 2013.pdf

24

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 23#

• Write a program that picks the students’ names and their test scores from excel sheet and outputs the following information: – The average score – Names of all students whose test scores are below

the average, with an appropriate message – Highest test score and the name of all students

having the highest score

Page 25: VBA Problems_Feb 2013.pdf

25

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Problem 24# • MyJava Café wants you to write a program to take orders from the

Internet. Your program asks for the item, its price, and if overnight shipping is wanted. Regular shipping for items under $10 is $2.00; for items $10 or more shipping is $3.00. For overnight delivery add $5.00. For example, the output might be:

• Enter the item: Tuna Salad • Enter the price: 450 • Overnight delivery (0==no, 1==yes): 1 • Invoice: Tuna Salad 4.50 • Shipping 7.00 • Total 11.50

Page 26: VBA Problems_Feb 2013.pdf

26

Copyright © Ivy Professional School - 2009-10 (All Rights Reserved)

Visit Ivy’s Blog for Career Tips, Latest Info, Job Alerts - www.ivyproschool.com/blog

Interact with us at -

Ivy Professional School

14 B | Camac Street | Kolkata – 17 www.ivyproschool.com | [email protected]

T: 033 400 11221 | SMS: 9748 441111