Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java language How to fix error on line 7 line.lastIndexOf(()).trim(). I get an error saying Cannot invoke trim() on the primitive type int 1.import java.util.Scanner;

Java language How to fix error on line 7 line.lastIndexOf(("")).trim(). I get an error saying "Cannot invoke trim() on the primitive type int" 1.import java.util.Scanner;

2.public class BankWithdrawal {

3.public static void main (String[]args) {

4.Scanner scan = new Scanner(System.in);

5.System.out.println("Enter first name, last name, and amount of money you want to withdraw: ");

6.String line = scan.nextLine();

7.String name = line.substring(0, line.lastIndexOf(("")).trim();

8.float money = Float.parseFloat(line.substring(line.lastIndexOf(""),line.length()).trim());

9.System.out.println("Hi "+name+"! You would like to withdraw $"+money+".equals(Thanks!");

10.}

11.}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions