Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have entered the following code in NetBeans to calculate objects sales tax: package SellItems; import java.util.Scanner; public class SellItems{ public static void main(String[] args)

I have entered the following code in NetBeans to calculate objects sales tax:

package SellItems; import java.util.Scanner; public class SellItems{ public static void main(String[] args) {

// the local variables used for the calculation float itemprice=0.0f; float total=0.0f; float tax=0.0f; float finalcost=0.0f; // the string variable that will hold all the itemprices inputted by delimiting them with semicolon String itempriceString=""; Scanner sc=new Scanner(System.in); System.out.println("Enter Item Prices one below the other. Type 0 to stop"); //array to accept input until the user enters zero do { itemprice = sc.nextFloat(); // accept the float data into itemprice if(itemprice != 0) // if the entered value is not zero, it is concatenated to the itemPriceString delimited by ; itempriceString = itempriceString + itemprice + ";" ; }while(itemprice!=0); // The split method is used to split a string based on some delimiter, say, ; and stores all individual data into string array String s[] = itempriceString.split(";"); //A float array is created using the length of the above string array float[] itemPriceArray = new float[s.length]; //loop the float array to convert every string input to float value using Float.parseFloat method for(int i=0;i { itemPriceArray[i] = Float.parseFloat(s[i]); total = total + itemPriceArray[i]; // find the total } tax = total * 0.07f; finalcost = total - tax; // Printing the details System.out.println("The list of item prices "); System.out.println("======================= "); for(int i=0;i { System.out.println(itemPriceArray[i]); } System.out.println("Sub Total :: "+ total); System.out.println("Tax :: "+ tax); System.out.println("Final Cost:: "+ finalcost); } }

I am receiving:

> Task :compileJava UP-TO-DATE > Task :processResources NO-SOURCE > Task :classes UP-TO-DATE

> Task :run FAILED Error: Could not find or load main class SellItems.Main Caused by: java.lang.ClassNotFoundException: SellItems.Main

FAILURE: Build failed with an exception.

* What went wrong: Execution failed for task ':run'. > Process 'command 'C:\Program Files\Java\jdk-13.0.1\bin\java.exe'' finished with non-zero exit value 1

* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

The main class and package all appear to be named correctly.

I attempted to run another piece of basic code, and still received this message. This leads me to believe the issue is not with the code, but with NetBeans, or how I am using NetBeans. I have attempted to uninstall and reinstall the program but am still receiving this message. Any information is helpful.

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

How To Build A Million Dollar Database

Authors: Michelle Bergquist

1st Edition

0615246842, 978-0615246840

More Books

Students also viewed these Databases questions

Question

Should Jessica qualify for a 504 Plan? Why or why not? (D10)

Answered: 1 week ago

Question

Decision Making in Groups Leadership in Meetings

Answered: 1 week ago