Q1:
Write a Program in C++ which completes following requirements:
a. Create a class, having a static function printing some information
and invoke that method using scope resolution operator.
b. Try to access non-static data members from static method and
write in comments what happens.
c. Declare and initialize a static variable as counter in a function
(increment it in every call) and call it multiple times printing the
change in value
d. Write about your observations while making this assignment in a
word file about static variables and static methods.
Based on Control Structure Selection and Control Structure Looping, answer the following questions:
Write a program that will ask the user to input n positive numbers. The program will terminate if one of those numbers is not positive. Output :
https://cdn.discordapp.com/attachments/711213157854609461/839150310864846934/unknown.png
Based on Control Structure Selection and Control Structure Looping, answer the following questions:
Write a program that is able to compute some operations on an integer. The program writes the value of the integer and writes the following menu :
1. Add 1
2. Multiply by 2
3. Subtract 4
4. Quit
Code a program to get the number of students and the group size from the user. Calculate and display the number of groups that must be used to divide the students in the given group size. The last group would possibly not be filled. Display also the number of students in the last group.
Section 6.9 of your textbook ("Debugging") lists three possibilities to consider if a function is not working.
What is the definition of precondition and post condition statement
i need help on assignment 3 chatbot for computer science
Rearrange Numbers in String
Given a string, write a program to re-arrange all the numbers appearing in the string in decreasing order. Note: There will not be any negative numbers or numbers with decimal part.
The input will be a single line containing a string.
The output should be a single line containing the modified string with all the numbers in string re-ordered in decreasing order.
For example, if the given string is "I am 5 years and 11 months old", the numbers are 5, 11. Your code should print the sentence after re-ordering the numbers as "I am 11 years and 5 months old".
Sample Input
I am 5 years and 11 months old
Sample Output
I am 11 years and 5 months old
The purpose is to create Circle and Triangle class by inheriting the Shape Class. Both the inherited classes should override the WhoamI() method of the Shape Class. The code has some bugs. Identify the Bugs and fix them.
public class Shape
{
private void WhoamI()
{
Console.WriteLine("I m Shape");
}
}
class Triangle : public Shape
{
public virtual void WhoamI()
{
Console.WriteLine("I m Triangle");
}
}
public class Circle : public Shape
{
void WhoamI()
{
Console.WriteLine("I m Circle");
}
}
class Program
{
static void Main(string[] args)
{
Shape s; s = new Triangle();
s.WhoamI();
s = new Circle();
s.WhoamI();
Console.ReadKey();
}
}