Answer:
A light bulb produces light from electricity
True
Dhahvdbdbrhhehebdbdbbdbd sorry it has to be longer ahhshdjdjhsjdjdbdnbfbfjfj
Rapid prototyping! I am sure that is correct
Answer:
The solution code is as below:
- Scanner input = new Scanner(System.in);
- System.out.print("Input a string: ");
- String inStr = input.nextLine();
- int strLen = inStr.length();
-
- while(inStr.equals("Quit") != true && inStr.equals("quit") !=true && inStr.equals("q") != true){
-
- for(int i= 0; i < strLen; i++){
- System.out.print(inStr.charAt(strLen - 1 - i));
- }
-
- System.out.println();
- System.out.print("Input a string: ");
- inStr = input.nextLine();
- strLen = inStr.length();
Explanation:
Firstly, we create a Scanner object,<em> input</em> (Line 1).
Next, we use the Scanner object nextLine() method to get a text input from user (Line 3).
We create a while loop and set the condition so long as the input text is not equal to "Quit", "quit" or "q" (Line 6), the program should proceed to print the input text in reverse (Line 8-10). To print the text in reverse, we can apply the expression<em> length of string - 1 - current index</em>. This will ensure the individual letter is read from the last and print the text in reverse.
Next, prompt the user to input a new text (Line 13-14) and repeat the same process of printing text in reverse so long as the current input text is not "Quit", "quit" or "q".
Answer:
import java.util.*;
public class calcarms
{
public static void main(String [] args)
{
Scanner input = new Scanner(System.in);
//Declare Variable
int num;
//Initialize num to 0
num = 0;
//Print heading
System.out.println("Armstrong Numbers\t\tDifference between Successive Armstrong Numbers");
//Call Armstrong method
boolean result = Armstrong(num);
}
public static boolean Armstrong(int num)
{
int nums;
//Initialize old_Arms and new_Arms to 0
int old_Arms =0; int new_Arms = 0;
for(int i = 0;i<=500;i++) //Iterate from 0 to 500
{
nums = i;
int temp,calc = 0;
temp = nums;
//Check individual digit of each number
while(nums > 0)
{
int a=nums%10;
nums/=10;
calc+=(a*a*a);//Find cube of number
}
if(temp == calc) //Check if number is armstrong
{
new_Arms = calc;
old_Arms = new_Arms - old_Arms;
System.out.println(calc+"\t\t\t"+old_Arms);//Print
old_Arms = calc;
}
}
return true;
};
}
Explanation:
Comments are used to explain difficult lines