Latest Posts

If you really have put it all in the main method then you will have no non-static variables, so you cannot get the same message. Let's see your latest version of the PriceCalculator class.

please call that callender function again, after the innerHTML insert

Dani 1,700

Sorry for the bad experience in the first place, Mr.M.

INTERSECT(p1,p2)
1 answer <----()
2 while p1 not equal Nil and p2 not eqaul Nil
3 do if docId(p1) = docId(p2)
4 then ADD (answer, docId(p1))
5 p1 <--- next(p1)
6 p2 <---- next(p2)
7 else if docId(p1) < docId(p2)
8 then p1<--- next(p1)
9 else p2<--- next(p2)
10 return answer

What I've done on other distros is yes to your question 1. After I have a working install I add users later.

"Red Hat uses strict trademark rules to restrict free re-distribution of its officially supported versions of Red Hat Enterprise Linux"

So this is a Linux you pay for? Sorry, I'd go get a really free Linux.

Don't worry, it's not really your fault. You are roughly the one millionth person to be trapped by this stupidity in the design of the Scanner clsss.

Here's the explanation (it uses ints, but doubles work the same way).

You have some input with an int followed by some text, eg
101
John Doe
... and you try to read it with
int num = scanner.nextInt();
String name = scanner.nextLine();
... and name is an empty String ("")!

Here's why:
Your input looks like this with the new line characters shown explicitly
101\nJohn Doe\n
nextInt takes the int value from the scanner, and stops when it finds a chaacter that's not part of an int, so it takes the "101", leaving this in the scanner
"\nJohn Doe\n"
then nextLine takes everything up to the first \n character - a zero-length String ("").

Possible fixes:

  1. Add add extra nextLine() between the nextInt and the real nextLine to clear the unwanted \n. This may be difficult if the nextInt and the nextLine are in different areas of code which are not always executed together.
  2. Give up on nextInt (etc) and just read whole lines and parse then into ints (etc) with Integer.parseInt (etc) - in which case you can junk the whole scanner and use a BufferedReader instead.
    new BufferedReader(new InputStreamReader(System.in))

  3. Use this class instead of Scanner:
    https://www.daniweb.com/programming/code/506346/a-simpler-safer-alternative-to-java-util-scanner

That's right.
The only thing the PriceCalculator class does is to run a test case. You can put all that into the main method. There's no need to create an instance, or to have instance variables. Local variables in the main method will do.

guffadi commented: It still gives me the same error message when I put everything in my main method +0
import java.util.Scanner;

 class Room_Dimension
{

    private double length;
    private double width;

    public Room_Dimension(double length, double width) 
    {
        this.length = length;
        this.width = width;
    }

    public void setLength(double length) 
    {
    this.length = length;
    }

    public void setWidth(double width) 
    {
    this.width = width;
    }

    public double getLength() 
    {
        return length;
    }

    public double getWidth() 
    {
        return width;
    }

    public Room_Dimension(Room_Dimension roomDimensions)
    {
        this.length = roomDimensions.getLength();
        this.width  = roomDimensions.getWidth();
    }

    public double getArea() 
    {
        return length * width;
    }

}

 class Room_Flooring 
{
    private String floorMaterial;
    private Room_Dimension roomDimensions;
    private double cost_of_material;

    public Room_Flooring(Room_Dimension roomDimensions, String floorMaterial) 
    {
        this.roomDimensions = roomDimensions;
        this.floorMaterial = floorMaterial;
        this.cost_of_material = cost_of_material;
    }

    public Room_Dimension getSize()
    {
        return roomDimensions;
    }

    public void setFloorMaterial(String floorMaterial)
    {
        this.floorMaterial = floorMaterial;
    }

    public String getFloorMaterial()
    {
        return floorMaterial;
    }

    public double getCost_of_Material(String floorMaterial)
    {
        if (floorMaterial == "NormalTile")
        {
            cost_of_material = 2.0;
        }

        if (floorMaterial == "FancyTile")
        {
            cost_of_material = 4.0;
        }

        return cost_of_material;
    }

    public Room_Flooring(Room_Flooring roomFlooring)
    {
        this.roomDimensions = roomFlooring.roomDimensions;
        this.floorMaterial     = roomFlooring.getFloorMaterial();
        this.cost_of_material = roomFlooring.getCost_of_Material(floorMaterial);
    }

    public double getTotalCost() 
    {
        return (getCost_of_Material(floorMaterial)) * roomDimensions.getArea();
    }

    public String toString()
    {
        return ""+ getTotalCost() +"" ;
    }

}

public class Pricing 
{
    public static void main(String[] args) 
    {
        System.out.print('\u000C');

        Scanner room = new Scanner(System.in);

        // Get the length of the room.
        System.out.println("Enter the length of room: ");
        double length = room.nextDouble();

        // Get the width of the room.
        System.out.println("Enter the width of room: ");
        double width = room.nextDouble();

        System.out.println("Enter the floor material that you want- NormalTile or FancyTile: ");
        String ...

rproffitt ,

actually I don't have much time to start Project on my own. This is interesting topic, but time consuming & team dependent.
I just wanted to start project where programmers can join & help to OS development.

As I'm reading more on this topic, understanding the actual problems in overall development.

Just thinking for free alternative to running Windows applications.

(banging head on RHEL 7.6 doors)

rproffitt commented: Few I know run that distro. "Red Hat uses strict trademark rules to restrict free re-distribution of its officially supported versions" so that's why. +15
xrjf 178

I see tag <asp:Panel in line #9 open but never closed, is it?

I've just installed RHEL 7.6. I've installed Base environment: Server with GUI with all addons for selectred environment

During Installation I created Root Password & created user form User Creation with, Make this user administrator option

Now, post install & after successful login to RHEL environment, I'm unable to install any software or access KUser to edit user permission or change user group

While installing anything it gives error something went wrong, Error msg when trying to use KUser , Error opening /etc/shadow for reading

  1. Should I install again with Root only?
  2. How to give root permissions to user created during Installation?

Ref:- Installation of “Red Hat Enterprise Linux (RHEL) 7.0” with Screenshots

Need books or tutorials to working in RHEL7 GUI

xrjf 178

Sorry for the inconvient. There were extra lines not needed.

    Sub Main()
        Try
            prependTextToAllLines("Append.txt")
            Console.Write("Process succeeded. Press Enter key to exit.")
            Console.ReadLine()
        Catch ex As Exception
            Console.WriteLine(ex.ToString)
            Console.ReadLine()
        End Try

    End Sub
    Sub prependTextToAllLines(path As String)
        Try
            Dim fsw As New FileStream(path, FileMode.Open, FileAccess.Write, FileShare.Read)
            Dim sw As New StreamWriter(fsw)
            Dim fs As New FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
            Dim sr As New StreamReader(fs)
            Dim lineNum As Int32 = 1
            Do
                Dim sCurrLn As String = sr.ReadLine
                Dim sPrepend As String = String.Format("Line #{0:0000000} ", lineNum)
                lineNum += 1
                sw.WriteLine(sPrepend + sCurrLn)
            Loop While Not sr.EndOfStream
            sr.Close()
            sw.Close()
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
End Module
xrjf 178

For some reason I don' t know, yesterday the code was working and today it fails. So, I've rewritten the code and it is:

Sub Main()
    Try
        prependTextToAllLines("Append.txt")
    Catch ex As Exception
        Console.WriteLine(ex.ToString)
        Console.ReadLine()
    End Try

End Sub
Sub prependTextToAllLines(path As String)
    Dim bRet As Boolean = False
    Dim fs As FileStream = Nothing
    Dim fsw As FileStream = Nothing
    Dim sr As StreamReader = Nothing
    Dim sw As StreamWriter = Nothing
    Try
        fsw = New FileStream(path, FileMode.Open, FileAccess.Write, FileShare.ReadWrite)
        sw = New StreamWriter(fsw)
        fs = New FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
        sr = New StreamReader(fs)
        Dim lineNum As Int32 = 1
        Dim fileLen As Long = fs.Length
        Dim currBufferLine As Int32 = 0
        Dim EndofBuffer As Int32 = -1
        Dim rdPos As Long = 0
        Dim wrPos As Long = 0
        Do
            Dim sCurrLn As String = sr.ReadLine
            Dim sPrepend As String = String.Format("Line #{0:0000000} ", lineNum)
            lineNum += 1
            sw.WriteLine(sPrepend + sCurrLn)
        Loop While Not sr.EndOfStream
        sr.Close()
        sw.Close()
        bRet = True
    Catch ex As Exception
    End Try
End Sub

I think have sorted this problem out now, thanks!

Line 107
getArea is a method in the RoomDimension class, but you try to call it using an instance of RoomFlooring
(and vice-versa for the material costs)

ps
Line 102
your main method is declared as an instance method but it should be static

pps
Java conventions are to use camel case and no underscores for member names, eg roomDimensions, getMaterialCost

guffadi commented: If i make my main method static, it says : non-static variable room flooring cannot be referenced from a static context +0

@Comeody.If so that (You don't have the password to unprotect the sheet),all you need to do is unlock it for editing anything in a given worksheet.
Now refer to it: https://www.androidphonesoft.com/resources/excel-password-cracker.html

Thanks to Dani queen, I was also affected by this as well, tried to reset password but the email wasn't sent to me, I contacted her about this and she assisted me instantly. I was about to loose hope in gaining back my Daniweb account. Thank you Dani.

@c. Sometimes folk leave out a key detail Such as "I don't have the password to unprotect the sheet." You didn't write that so I proceed as it's not a lost password issue. Just one where the user has forgotten where the menus are.

Google didn't do much help for the programs it suggest

I wonder about line 107. room_flooring is called out but I can't find where that method is in that class.

You can skin this particular cat in many ways. here are 2 examples, neither of which I've given much thought to - so there's probably a few better ways out there. Anyway...

<?php
$inputArray =
    [
        [
            'SupSKU',
            'MfrSKU',
            'Cost'
        ],
        [
            'A',
            '11742-4',
            47.25
        ],
        [
            'B',
            '11742-4',
            283.5
            ],
        [
            'C',
            '0904101',
            995
        ]

    ];

//Using array functions and a reduced loop
function getSupSKU( $source, $SKU )
{
    $valArray = array_filter( $source, function ($var) use ($SKU) {
        return ($var[1] == $SKU);
    }); //filter array to just contain 11742-4
    $maxCost = max( array_column( $valArray, 2 ) ); //get max cost
    foreach($valArray as $item) {
        if ($item[2] === $maxCost) return $item[0]; //return FIRST max hit
    }
    return false;
}

//Using a big loop
function getSupSKU2( $source, $SKU )
{
    $output = false;
    $maxCost = 0;
    foreach($source as $item) {
        if ($SKU === $item[1] && $item[2] > $maxCost){
            $maxCost = $item[2];
            $output = $item[0];
        }
    }
    return $output;
}

$SKU = '11742-4';

array_shift( $inputArray ); //get rid of labels

echo getSupSKU( $inputArray, $SKU );

echo getSupSKU2( $inputArray, $SKU );

//EDIT - try some PHP execution timers on different length arrays - the straight loop consistently outperformed the array function script by around a factor of 3 in simple tests.

 /** This code is supposed to take the user input of the length
 and breadth of the room in one class, get the user input of the 
material and cost from the other class and calculate the total cost.*/

import java.util.Scanner;

//My first class
class RoomFlooring
{
private String FloorMaterial;
private double material_cost = 0;

public void setFloorMaterial(String FloorMaterial)
{
System.out.print('\u000C');

// Choosing the floor material
Scanner Floor = new Scanner(System.in);
System.out.println("Choose your floor material: FancyTile or NormalTile: ");

FloorMaterial = Floor.nextLine();
}

 public String getFloorMaterial()
 {
    return FloorMaterial;
}
 // determining the cost according to the floor materials
public void setMaterial_Cost(double material_cost)
 {
 if (FloorMaterial == "FancyTile")
{
    material_cost = 2;
}

else
{
    material_cost = 4;
}

}

public double getMaterial_Cost()
 {
 return material_cost;
}

}
// class to set and get the room dimensions from the user 
class RoomDimensions
{ 

private double length;
private double width;
// getting the length of the room
public void setLength(double length)
{
    Scanner room = new Scanner(System.in);
    System.out.println("Enter the length of the room: ");

    length = room.nextDouble(); 

}
// getting the width of the room
public void setWidth(double width)
{
    Scanner room = new Scanner(System.in);
    System.out.println("Enter the width of the room: ");

    width = room.nextDouble();

}

public double getLength()
{
    return length;
}

public double getWidth()
{
    return width;
}
// calculating the area of the room
public double getArea()
{
    return length*width;
}

}
//Public class that has the main method
public class PriceCalculator
{
 private RoomFlooring room_flooring ;
 private ...

This sounds like a very bad idea for two reasons:

  1. The code is overly complex (tricky) for the task and I believe that with very few exceptions, clear code is always preferable to tricky code.
  2. If anything breaks the process midway through the original file is corrupted.

Having said that, I admit that it was an interesting and clever approach.

rproffitt commented: In the news, MySpace server transition loses over a decade of uploads. "My code is quite the trick." +15
xrjf 178

@rproffitt: If the file is large and assuming we can buffer a first bunch of lines so that streamreader and streamwriter will never overlap:

        Try
            Dim path As String = "Append.txt"
            Using fs As New FileStream(path, FileMode.Open, FileAccess.ReadWrite, FileShare.None)
                Dim sr As New StreamReader(fs)
                Dim sw As New StreamWriter(fs)
                Dim lineNum As Int32 = 1
                Dim fileLen As Long = fs.Length
                Dim linesToBuffer As Int32 = 3
                Dim currBufferLine As Int32 = 0
                Dim vBuffer(linesToBuffer - 1) As String
                Dim EndofBuffer As Int32 = -1
                Dim rdPos As Long = 0
                Dim wrPos As Long = 0
                For i = 0 To vBuffer.Length - 1
                    vBuffer(i) = sr.ReadLine
                Next
                rdPos = fs.Position
                Do
                    fs.Seek(wrPos, SeekOrigin.Begin)
                    sw.WriteLine(String.Format("Line #{0:0000000} ", lineNum) + vBuffer(currBufferLine))
                    wrPos = fs.Position 
                    ' if wrPos >= rdPos signifies buffer too small'
                    If rdPos < fileLen Then
                        fs.Seek(rdPos, SeekOrigin.Begin)
                        vBuffer(currBufferLine) = sr.ReadLine
                        rdPos += vBuffer(currBufferLine).Length + 2
                        lineNum += 1
                    Else
                        If EndofBuffer = -1 Then
                            sr.Close()
                            EndofBuffer = linesToBuffer
                        End If
                        EndofBuffer -= 1
                        If EndofBuffer < 0 Then Exit Do
                    End If
                    currBufferLine = (currBufferLine + 1) Mod linesToBuffer
                Loop
                sw.Close()
            End Using
        Catch ex As Exception

        End Try
rproffitt commented: Now throw this a zero byte file. Excellent examples where something simple grows and grows to cover every condition. +0

That seems like the type of task more suited to a script than an app. If you copy the following into a file named prefix.vbs you can do what you requested.

set fso = CreateObject("Scripting.FileSystemObject")

if wscript.arguments.unnamed.count <> 2 then
    Wscript.Echo "prefix <filename> ""string"""
    Wscript.Quit
end if

infile  = wscript.arguments.unnamed(0)
outfile = infile & ".pre"
prefix  = wscript.arguments.unnamed(1)

if not fso.FileExists(infile) then
    Wscript.Echo "File '" & infile & "' not found"
    Wscript.Quit
end if

set fi = fso.OpenTextFile(infile)
set fo = fso.OpenTextFile(outfile,2,True)  '2=write True=create if needed

do while not fi.AtEndOfStream
    line = fi.ReadLine
    fo.WriteLine prefix & line
loop

fi.Close
fo.Close

It's a lot less complicated than the equivalent code in vb.Net. The output goes to the file <yourfile>.pre. For example, if you feed it myfile.txt you will get myfile.txt.pre. Once you verify the results you can rename it.

Thanks xrjf for your reply.

I have done as you suggested, that is:

<body>

      <form id="form1" runat="server" method="post">

            <div>

       <asp:Label ID = "LblDate" runat="server" CssClass="dateStyle" Text="Label"></asp:Label>

        <asp:Panel ID="pnlFormFields" runat="server">
        <asp:Panel ID="pnlThankYouMessage" runat="server" CssClass="panel" Visible="False">

          Thank you. Your message has been sent.

         </asp:Panel>
        </div>

        <header>

Contact details

</header>

   <div id="footer" class="footerdiv">

Form fields

  </div>          

            </form>     

     </body>

I have run it through a HTML validator for stray divs, etc, and get no errors. But in my aspx.vb file, I still see the 3 errors (attached)

I am getting a sever error related to a DotNetAuth file, but doubt that is related to the above problem I have.

Is it where I have those three lines, that is, under Protected Sub Page_Load, that may be causing the problem?

Thanks again.

xrjf 178

Consider reading all the lines at the beginning and, then, prepending the line number, like in:

        Try
            Dim vLines() As String = IO.File.ReadAllLines("Append.txt")
            Using sw As New StreamWriter("Append.txt")
                For i As Int32 = 0 To vLines.Length - 1
                    sw.Write(String.Format("Line #{0:0000} ", i) + vLines(i) + vbCrLf)
                Next
            End Using
        Catch ex As Exception

        End Try
rproffitt commented: I'd like to try that on a 4+ terabyte file just to see what vb.net would do. There are reasons to code this with input and output files. +15

https://validator.w3.org/nu/?doc=https%3A%2F%2Ffree-slots.games%2F tells me this may have been a rush job. Don't submit this site to your prof for grading.

In psuedocode to do this we read a file line by line then insert the text on each line then write the line to another file.
At the end of the file we close both files. Optionally you could delete the source and rename the edited file to the source's name.