I'm getting these 2 errors and haven't got a clue whats causing them please
java 43: illegal start of type
for (i=0;i< Number_of_squar es; i++)
java 215 identifier expected
}
heres the whole code -
import java.util.*;
-
-
public class areaCalculation3
-
{
-
// Set-up data input
-
-
Scanner data_input = new Scanner(System.in);
-
public static double valid_data(String input_message)
-
{
-
Scanner data_input = new Scanner(System.in);
-
boolean valid_data = false;
-
double data = 0;
-
-
do
-
{
-
System.out.print(input_message);
-
-
try
-
{
-
data = data_input.nextDouble();
-
valid_data = true;
-
}
-
catch (InputMismatchException e)
-
{
-
// Remove invalid data
-
data_input.next();
-
// Output error message
-
System.out.println("Invalid input, please enter a valid number.");
-
}
-
-
} while (! valid_data);
-
-
return data;
-
}
-
-
//method for the area of the square
-
-
public static void area_of_square(String area);
-
// Declare variables
-
double Length, Number_of_squares, Increment, Area, value_of_increment, i;
-
String area;
-
-
for (i=0;i< Number_of_squares; i++)
-
{
-
Area = Length * Length;
-
-
System.out.printf("%nLength of square: %f", Length);
-
System.out.printf(", Area of square: %f", Area);
-
-
Length = Length + Increment;
-
}
-
{
-
Scanner data_input = new Scanner(System.in);
-
-
// Declare variables
-
double Length, Number_of_squares, Increment, Area, i;
-
string area;
-
-
Length = valid_data("Please enter the length: ");
-
-
Number_of_squares = valid_data("Please enter the number of triangles");
-
-
Increment = valid_data("Please enter the increment: ");
-
-
for (i=0;i<Number_of_squares;i++)
-
{
-
Area = Length * Length;
-
System.out.printf("%nLength of square: %f", Length);
-
System.out.printf(", Area of square: %f", Area);
-
-
Length = Length + Increment;
-
}
-
}
-
//Rectangle area method
-
public static void area_of_rectangle(String [] args)
-
{
-
// Set-up data input
-
Scanner data_input = new Scanner(System.in);
-
-
// Declare variables
-
double Length, Width, Number_of_rectangles, Increment, Area, i;
-
String area;
-
Length = valid_data("Plase enter the length: ");
-
Width= valid_data("Plase enter the width: ");
-
-
Number_of_rectangles = valid_data("Please enter the number of rectangles");
-
-
Increment = valid_data("Please enter the increment: ");
-
-
for (i=0;i<Number_of_rectangles;i++)
-
{
-
Area = Length * Width;
-
-
System.out.printf("%nLength of rectangles: %f", Length);
-
System.out.printf("%nWidth of rectangles: %f", Width);
-
System.out.printf(", Area of rectangles: %f", Area);
-
-
Length = Length + Increment;
-
}
-
}
-
-
//Area of Triangle method
-
public static void area_of_triangle(String [] args)
-
{
-
// Set-up data input
-
Scanner data_input = new Scanner(System.in);
-
-
// Declare variables
-
double Base, Height, Number_of_triangles, Increment, Area, i;
-
String area;
-
-
Length = valid_data("Plase enter the base: ");
-
Height = valid_data("Plase enter the Height: ");
-
Number_of_triangles = valid_data("Please enter the number of triangles");
-
-
Increment = valid_data("Please enter the increment: ");
-
-
for (i=0;i<Number_of_triangles;i++)
-
{
-
Area = Base/2 * Height;
-
-
System.out.printf("%nBaseof triangle: %f", Base);
-
System.out.printf(", Area of square: %f", Area);
-
-
Base = Base + Increment;
-
Height= Height+Increment;
-
}
-
}
-
-
//Circle method
-
public static void area_of_circle(String [] args)
-
{
-
// Set-up data input
-
Scanner data_input = new Scanner(System.in);
-
-
// Declare variables
-
double Radius, Number_of_circles, Increment, Area, i;
-
-
Radius = valid_data("Plase enter the radius: ");
-
-
Number_of_circles = valid_data("Please enter the number circles");
-
-
Increment = valid_data("Enter the increment: ");
-
-
for (i=0;i<Number_of_circles;i++)
-
{
-
Area = Radius * Radius * 3.1415927;
-
-
System.out.printf("%nRadius of Circle: %f", Radius);
-
System.out.printf(", Area of square: %f", Area);
-
-
Radius = Radius + Increment;
-
}
-
}
-
public static void main (String [] args)
-
{ //Declare variables
-
int user_choice;
-
boolean quit = false;
-
String continue_pref;
-
-
//Menu System
-
do
-
{
-
Scanner data_input = new Scanner(System.in);
-
-
System.out.printf ("%n%nPlease choose one of the following:%n%n");
-
System.out.println("1. Calculate The Area Of A Square");
-
System.out.println("2. Calculate The Area Of A Rectangle");
-
System.out.println("3. Calculate The Area Of A Triangle");
-
System.out.println("4. Calculate The Area Of A Circle");
-
System.out.printf("5. Quit %n%n Please make your choice: ");
-
-
try
-
{
-
user_choice = data_input.nextInt();
-
}
-
catch (InputMismatchException e)
-
{
-
// Remove invalid data
-
data_input.next();
-
// Make data an invalid value
-
user_choice = -1;
-
}
-
-
//Get choice from user
-
user_choice = data_input.nextInt();
-
-
//Linking menu to methods
-
switch(user_choice)
-
{
-
case 1:
-
area_of_square(args);
-
break;
-
case 2:
-
area_of_rectangle(args);
-
break;
-
case 3:
-
area_of_triangle(args);
-
break;
-
case 4:
-
area_of_circle(args);
-
break;
-
case 5:
-
quit = true;
-
break;
-
default:
-
System.out.printf(" %n Typing error. %n Please Enter A Number Between 1 - 5.");
-
}
-
if (quit= true)
-
{
-
System.out.printf(" %n Typing error. %n Please Enter A Number Between 1 - 5.");
-
}
-
} while (continue_pref.equalsIgnoreCase("N"));
-
}
-
}
-
thanks in advance for any help
2 6631 horace1 1,510
Recognized Expert Top Contributor
you appear to have a ; on the end of -
public static void area_of_square(String area);
-
should it be? -
public static void area_of_square(String area)
-
{
-
// Declare variables
you appear to have a ; on the end of -
public static void area_of_square(String area);
-
should it be? -
public static void area_of_square(String area)
-
{
-
// Declare variables
Oh yes . I had missed that semi-colon also. Fter removing it, u may still get an eror about the variable "i" not having been declared. ie: variable i cannot be resolved. on the for loop try - for(int i=0; i<bla bla bla){
This shd work
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Grumble |
last post by:
Hello everybody,
(Disclaimer: I do not understand C++ templates.)
I've tried to make a testcase from the original code.
GCC 3.3.5 compiles with no warning, while GCC 3.4.3 rejects it. Could
somebody tell me if it because the code is illegal, and GCC 3.4.3's
stricter parser now rejects it, or is it some kind of regression?
|
by: Gabrielle A. Grün |
last post by:
Hi All,
Does anyone know a way around the illegal reference of a non-static
member? Thanks.
iNHERITANCE HIERACY
|
by: jacob navia |
last post by:
Hi
Suppose you have somewhere
#define BOOL int
and somewhere else
typedef BOOL int;
|
by: BlueTrin |
last post by:
Hello I was adapting a C version of SolvOpt in C++ to use it within a
virtual class.
However I am stuck with the overriding of evaluation and gradiant
functions.
cStepCurveEvaluator.cpp
cStepCurveEvaluator.cpp(14) : error C2296: '.*' : illegal, left operand
|
by: LuB |
last post by:
Is this somehow illegal?
template<typename T>
class A {
public:
private:
| |
by: Manish |
last post by:
The code is as ...
$folderlistfile = $path."xmlfile.xml";
/*
<list>
<details id="2">
<name>Books</name>
|
by: mole40 |
last post by:
Hello! I'm very new to writing java. And I keep getting the "Illegal Start of Type" error. I've tried everything to fix it. can anyone help me?
import java.util.*;
class ClockTalk {
public static void main(String arguments) {
//get current time and date
Calenda now = Calendar.getInstance();
int hour = now.get(Calendr.HOUR_OF_DAY);
int minute = now.get(Calendar.MINUTE);
|
by: Lambda |
last post by:
The code is simple:
// Token.h
#ifndef TOKEN_H
#define TOKEN_H
#include <vector>
#include <string>
class Token
|
by: MrHenry007 |
last post by:
Hello!
I'm fairly new to c++ but I have been following tutorials and have created functions before, but not one using a string. I can't work out what the problem is here.
The function is supposed to accept a file location, open the file, search for a phrase, and return a result if the certain phrase is found, otherwise return nothing. Then the result is written to a text file later in the program.
Im using visual c++ 2008 and it is...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |