Dear all,
I have a program to code which would take several lines of input from user (a fruit name, it's price per kg and the number of kgs sold). Each seperated by a space. It would then output the total money made and the name of the fruit that made maximum sales. And, it would use sentinel "Stop" to halt the program.
Now, I know this is fairly easy to write. But, I have never used strings and I don't know where to begin. Hints?

this is what I have managed to write yet

import java.util.Scanner;

public class Q3_new{
    public static void main (String []a){
        Scanner input = new Scanner (System.in);
        String nameFruit= "";
        int priceFruit;
        int Profit=0 ;  
        int kgSold= 0;

               System.out.print("Please enter name of the fruit, price and kg sold");

             while (!nameFruit.equals("Stop"))
             {
              nameFruit=input.next();
              priceFruit=input.nextInt();
              kgSold=input.nextInt();

actually, I would write it a bit like this:

nameFruit = input.next();
while (!nameFruit.equalsIgnoreCase("Stop")){
  // read price and sold
  // add code to handle information

  nameFruit = input.next();
}

for more precise answers, you may want to clarify your question a bit further.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.