Answer:
public class PostAccount
{
public void withdraw(float savings)
{
if (savings >=0 )
{
IllegalArgumentException exception
= new IllegalArgumentException("Savings cannot be negative");
throw exception;
}
balance = savings - withdraw;
}
}
Explanation:
IllgalArgumentException is a type of NumberFormatException of runtime exception. Here in the program we have created an object of IllgalArgumentException class and after that we have thrown the error to show the condition if it does not satisfy the if condition.
I'm going to assume this is Java, because you said "method" meaning it will be some sort of object oriented language, and Java's really common. Here would be the full program, but you can just take the method out isolated if you need it.
package lastname;
public class LastName {
public static void main(String[] args) {
// Example usage:
String name = LastName.lastName("Garrett Acord");
System.out.println(name);
// Output: Acord G.
}
public static String lastName(String fullName)
{
String[] splitName = fullName.split(" ");
return String.format("%s %s.", splitName[1], splitName[0].substring(0,1) );
}
}
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.
Answer:
#include<iostream>
using namespace std;
void main()
{
int townA_pop,townB_pop,count_years=1;
double rateA,rateB;
cout<<"please enter the population of town A"<<endl;
cin>>townA_pop;
cout<<"please enter the population of town B"<<endl;
cin>>townB_pop;
cout<<"please enter the grothw rate of town A"<<endl;
cin>>rateA;
cout<<"please enter the grothw rate of town B"<<endl;
cin>>rateB;
while(townA_pop < townB_pop)//IF town A pop is equal or greater than town B it will break
{
townA_pop = townA_pop +( townA_pop * (rateA /100) );
townB_pop = townB_pop +( townB_pop * (rateB /100) );
count_years++;
}
cout<<"after "<<count_years<<" of years the pop of town A will be graeter than or equal To the pop of town B"<<endl;
}
Explanation:
Answer:
A
Explanation:
I saw it on another website and got it right