Answer and Explanation:
class Dis
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter values for a,b,c");
double a=sc.nextDouble();
double b=sc.nextDouble();
double c=sc.nextDouble();
String s=discriminant(a,b,c);
System.out.println(s);
}
public String discriminant(double a, double b, double c)
{
double result;
result=(
);
if(result<0)
return "no real solutions"";
else return "";
}
}
Note:This program is written in JAVA
Answer:
7/73
Explanation:
May has 31 days. 31 - 26 = 5. So there are 5 more days to the next month (June). June has 30 days. So Muslims fasted 35 days in total. 2017 had 365 days. 365 - 35 = 330 days were spent not fasting. So the fraction is 35/365. This fraction simplified would be 7/73.
Answer:
A. The mathematical formula for finding the area of a circle.
D. Instructions for setting up a new DVD player
E. A series of steps that moves a "lighting bot" around to turns on lights.
Explanation:
Algorithm is a systematic procedure (or process) that produces the answer to a question or the solution of a problem in a finite number of steps.
Option A is an algorithm. The mathematical formula for finding the area of a circle gives a solution to a problem. The problem is finding area of a circle and the formula gives the step by step procedure finding the area of a circle.
Option B is not an algorithm. Option B just provide a list of your favourite animals and it doesn't answer a question we know about.
Option C is not an algorithm. A problem statement is still a problem with no solution whereas algorithm provides solution
Option D is an algorithm. It provides the step by step procedures for setting up a new DVD player
Option E is an algorithm. It provides a series of steps that moves a lighting bot around to turns on lights, so it provides a solution.
Explanation:
Execution step:
1. Starting the program
2. It will get the animal name
3. Check whether the animal eats only plants. Then it prints "Herbivore". If the condition is false, it prints "carnivore".
4. Stop the program
To identify input, output and decision:
Start and Stop (oval): These are neither input nor output
Does it eat only plants?: Decision making statement ("d")
Read the names of the animals(Parallelogram): Input ("i")
Print Herbivore, Print Carnivore: Output "o"
Scenario 1: Input is lion
1. Start
2. Reads the input as "lion"
3. Check if lion eats only plants. So here it is false
4. Print "Carnivore"
5. Stop
Scenario 1: Input is Elephant
1. Start
2. Reads the input as "Elephant"
3. Check if lion eats only plants. So here it is true
4. Print "Herbivore"
5. Stop
Answer:
public static void main(String[] args) {
String ing[] = {"ten","fading","post","card","thunder","hinge","trailing","batting"};
for (String i: ing){
if (i.endsWith("ing")){
System.out.println(i);
}
}
}
Explanation:
The for-loop cycles through the entire list and the if-statement makes it so that the string is only printed if it ends with "ing"