The issue arises because the string you are trying to print is not a string, rather a float value. Item1, item2 and item3 are strong values (if you type some alphabets in it and not just numbers), but itemonecost, itemtwocost, and itemthreecost are explicitly type casted to float. In line 22, 23, and 24 you’re trying to print a float, by adding it with the string. One cannot add numbers to string. Rather you can type cast the itemcost to string while printing.
Add str(itemonecost) instead of itemonecost in print statement. Do this for other float variables too.
However do note that there are multiple ways to correct this issue, and I’ve just pointed one out.
Answer:
import java.util.*;
public class MyClass {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
System.out.print("Input a word: ");
String userinput = input.nextLine();
for(int i =0;i<userinput.length();i+=2) {
System.out.print(userinput.charAt(i));
}
}
}
Explanation:
This line prompts user for input
System.out.print("Input a word: ");
This declares a string variable named userinput and also gets input from the user
String userinput = input.nextLine();
The following iterates through every other character of userinput from the first using iteration variable i and i is incremented by 2
for(int i =0;i<userinput.length();i+=2) {
This prints characters at i-th position
System.out.print(userinput.charAt(i));
Answer:
step 1:- start
step 2:-read principal amount, rate and time
step 3:- calculate interest using formula sI=((amount*rate*time)/100)
step 4:- print simple interest
step 5:- //CPP program to find compound interest for. //given values
The reasons why a switch port would have a status of errdisable include due to duplex mismatch and bad network interface.
<h3>What is a port?</h3>
A port simply means a software defined number associated to a network protocol that's transmits communication.
In this case, the reasons why a switch port would have a status of errdisable include due to duplex mismatch and bad network interface.
Learn more about port on:
brainly.com/question/4804932
#SPJ12