Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Microsoft Visual C# 2017 page 220 - 221 Please keep these as basic as possible s

ID: 3869961 • Letter: M

Question

Microsoft Visual C# 2017 page 220 - 221

Please keep these as basic as possible so that I can understand and follow how it was done.

9. Write an application named Sum200 that sums the integers from 1 through 200. Display the running total when the program is halfway complete (after the first 100 numbers), and at the end.

13. Write a program named CountVowels that accepts a phrase from the user and counts the number of vowels in the phrase. For this exercise, count both uppercase and lowercase vowels, but do not consider y to be a vowel.

One technique that could be used is a switch statement for vowels
** must use a loop technique to move through the string; no shortcut methods not covered in the book will be allowed **

The results should look like this:

CWindows system321cmd.exe Halfway through.... after 100 numbers, sum is 4950 The sum of the integers 1 through 20e is 20100 Press any key to continue. . .

Explanation / Answer

9)

//code for 9th ques

using System;

class Program
{
static void Main()
{
int i,j;
Console.WriteLine("Halfway through......");
int sum1=0,sum2=0;
for(i=1;i<100;i++){
sum1=sum1+i;
}
Console.WriteLine(" after 100 nymbers sum is {0}",sum1);
for(j=1;j<=200;j++){
sum2=sum2+j;
}
Console.WriteLine("The sum of integers 1 through 100 is {0}",sum2);
}
}

13)

//code for ques 13

using System;

class Program
{
static void Main()
{
int vowelsCount = 0,consCount = 0;
Console.WriteLine("Enter the word: ");
string strValue = Console.ReadLine();
for (int j = 0; j < strValue.Length; j++)
{
if (strValue[j] == 'a' || strValue[j] == 'A' || strValue[j] == 'e' || strValue[j] == 'E' || strValue[j] == 'i' || strValue[j] == 'I' || strValue[j] == 'o' || strValue[j] == 'O' || strValue[j] == 'u' || strValue[j] == 'U')
{
vowelsCount++;
}
else{
consCount++;
}
}
Console.WriteLine("The word {0} has {1} vowels and {2} consonents ." , strValue,vowelsCount,consCount);
}
}