It’s either b or c, but my final answer would be C
Answer:
#include <iostream>
using namespace std;
int main()
{
string str;
cout<<"Enter the string: ";
cin>>str;
for(int i=0;str[i]!='\0';i++){
if(str[i]=='e'){
str[i]='x';
}
}
cout<<"the string is: "<<str<<endl;
return 0;
}
Explanation:
First, include the library iostream for using the input/output instructions.
Create the main function and declare the variables.
Then, use the cout instruction and print the message on the screen.
cin store the string enter by the user into a variable.
After that, take a for loop and if-else statement for checking the condition if the string contains the 'e', then change that alphabet to 'x'.
This process continues until the string not empty.
Finally, print the updated string.
There’s 3 main ones accelerometer, gyroscope, and magnetometer.
Answer:
- import java.util.Scanner;
-
- public class Main {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.print("Input total sales of month: ");
- double totalSales = input.nextDouble();
-
- double stateTax = totalSales * 0.04;
- double countyTax = totalSales * 0.02;
- double totalSalesTax = stateTax + countyTax;
-
- System.out.println("County Tax: $" + countyTax);
- System.out.println("State Tax: $" + stateTax);
- System.out.println("Total Sales Tax: $" + totalSalesTax);
- }
- }
Explanation:
Firstly, create a Scanner object and prompt user to input total sales of month (Line 5-7). Next, apply the appropriate tax rate to calculate the state tax, county tax (Line 9 - 10). Total up the state tax and county tax to get the total sales tax (Line 11).
At last, print the county tax, state tax and the total sales tax (Line 13 - 15).