/    Sign up×
Community /Pin to ProfileBookmark

array required,but int found

“`
import java.util.Scanner;
public class project {
//method for 1d array
public static int firstD() {
Scanner sc = new Scanner(System.in);

System.out.println(“ENTER HOW MANY ITEM TO PURCHASE: “);
int item = sc.nextInt();

return item;
}

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);
System.out.println(“HIGH-END CAR SPAREPART PURCHASE SYSTEM”);

System.out.print(“Name : “);
String name = sc.nextLine();

System.out.print(“No Tel : “);
String tel = sc.nextLine();

System.out.print(“No Plat : “);
String plat = sc.nextLine();

function1();
}

public static void function1() {//starter method void with no prameter

Scanner sc = new Scanner(System.in);
System.out.println(” ACCESSORIES/SPAREPART PRICE (RM)”);
System.out.println(” a. Tyer 1200 “);
System.out.println(” b. Car Battery 1600″);
System.out.println(” c. Rim 3600″);
System.out.println(” d. Bumper 2500″);
System.out.println(” e. Sun Roof 1700″);
System.out.println(” f. Tinted 150″);

int item = firstD();
int[] sizeitem = new int[item];
for (int i = 0; i < sizeitem.length; i++) {//looping starter

System.out.print((i + 1) + “:”);

System.out.println(“CHOOSE ACCESSORIES/SPAREPART (a/b/c/d/e/f) : “);
char sparepart = sc.next().charAt(0);

System.out.println(” “);

System.out.println(“ENTER ACCESSORIES/SPAREPART PRICE : “);
double price = sc.nextDouble();

}

int k,total;

for ( k = 0; k < item; k++) {//start of calculation for looping
switch (item[k]) {//start of condition

case “a”: total = 1200;
break;
case “b”: total = 1600;
break;
case “c”: total = 3600;
break;
case “d”: total = 2500;
break;
case “e”: total = 1700;
break;
case “f”: total = 150;
break;
}//end of condition
}//looping ending
}//end method void with no prameter
}
“`

please find what that makes an error

to post a comment
Java

2 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumJan 21.2023 — Obviously your code ist Java, not Javascript. Changed the tag.

Please use code tags when posting code: `your code here` or triple backticks. I edited your posting accordingly.
Copy linkTweet thisAlerts:
@SempervivumJan 21.2023 — [[2,4],[19,32]]
×

Success!

Help @zack234 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...